Enterprise Application Development, Past Papers

Enterprise Application Development MSc IT 3rd Term Past Paper 2019 UOS

Enterprise Application Development MSc IT 3rd term past paper 2019 University of Sargodha

University of Sargodha M.Sc. IT 3rd term Enterprise Application Development (CS-4744) past paper 2019, retyped from the original paper, with solved answers below.

Solved answers

Q1 – Short questions

(i) Remote vs local client view: a remote client view (remote interface) lets clients in a different JVM, possibly on another machine, call an enterprise bean through RMI; arguments are passed by value and location is transparent. A local client view lets only clients in the same JVM/application call the bean; arguments are passed by reference, so calls are faster but not location independent.

(ii) How the JVM works: Java source is compiled to platform-independent bytecode (.class). The JVM’s class loader loads classes, the bytecode verifier checks them, and the execution engine interprets the bytecode or compiles it to native code with the JIT compiler, while managing memory with garbage collection — “write once, run anywhere”.

(iii) Java Swing: the javax.swing package provides lightweight, platform-independent GUI components (JFrame, JButton, JTextField, JTable) with pluggable look and feel, used to build desktop application clients.

(iv) toString(): a method of the Object class that returns a string representation of an object; it is overridden to give a meaningful description and is called automatically when an object is printed or concatenated with a string.

(v) Getters and setters: public methods that read (getX) and modify (setX) private fields; they provide encapsulation, allow validation, and follow the JavaBeans naming convention used by JSP and frameworks.

(vi) Security methodologies: declarative security (roles and constraints in deployment descriptors/annotations), programmatic security (isUserInRole(), getUserPrincipal() in code), authentication (basic, form, digest, client certificate), authorisation (role-based access), and transport security with SSL/TLS (confidentiality and integrity).

(vii) Java beans tier transaction: transactions in the EJB (business) tier, managed either by the container (container-managed transactions with attributes such as Required, RequiresNew, Mandatory) or by the bean (bean-managed using JTA UserTransaction), ensuring a group of operations is completed atomically (ACID).

(viii) Uses of stateless session beans: they hold no client-specific state between calls, so a small pool can serve many clients — used for independent operations such as currency conversion, sending e-mail, calculations, credit-card verification, and web service endpoints; highly scalable.

(ix) Authentication vs authorization: authentication verifies who the user is (e.g. username/password, certificate); authorization decides what the authenticated user is allowed to access (roles and permissions).

(x) In the deployment descriptors — XML files such as web.xml, ejb-jar.xml, application.xml and server-specific descriptors (or annotations), which the deployer can change at deployment time without changing code.

(xi) Browser clients send HTTP/HTTPS requests to the web tier — servlets and JSP pages running in the web container — which process the request (often calling EJBs or databases) and return dynamically generated HTML/XML.

(xii) Asynchronous integration: communication in which the sender does not wait for the receiver to process the message; messages are sent through message-oriented middleware (JMS queues/topics) and handled later, e.g. by message-driven beans, giving loose coupling and reliability.

(xiii) Package vs class: a class is a blueprint defining fields and methods of objects; a package is a namespace that groups related classes and interfaces (e.g. java.util), avoids name conflicts and controls access.

(xiv) Java IDEs: Eclipse, NetBeans, IntelliJ IDEA, JDeveloper, BlueJ, JCreator (and VS Code with Java extensions).

(xv) Multitier models: applications divided into logical tiers on different machines — client tier (browser/application), web tier (servlets/JSP), business tier (EJBs) and Enterprise Information System tier (databases, ERP). This improves scalability, maintainability and security.

(xvi) Benefits of component-based J2EE: reusable components; the container provides system services (transactions, security, persistence, pooling); portability across servers; separation of roles (developer, assembler, deployer); scalability and easier maintenance.

Q2 – When to use Servlets

A servlet is a Java class that runs in a web container and handles HTTP requests (doGet/doPost) to generate dynamic responses. Servlets are suitable when:

  • Dynamic content must be generated from user input or database data (search results, reports).
  • Form processing: reading and validating HTML form data, then storing it in a database.
  • Controller in MVC: a front-controller servlet receives all requests, calls business logic (EJBs/JavaBeans) and forwards to JSP views.
  • Session management: shopping carts, login sessions using HttpSession, cookies or URL rewriting.
  • Non-HTML output: generating images, PDF, JSON or XML, file download/upload.
  • Database access through JDBC with connection pooling, and acting as a gateway to back-end systems.
  • Filters and security: authentication checks, logging, compression, encoding.
  • Web services and REST endpoints, server-side communication with applets or mobile clients.

Advantages: efficient (one instance, multiple threads), portable, secure, and integrated with the J2EE container. For mostly presentation markup, JSP is preferred, with servlets handling the control logic.

Q3 – Types of J2EE clients

  • Web clients (thin clients): a web browser displaying dynamic pages (HTML, XML) generated by servlets/JSP in the web tier. They do not query databases or run business rules; heavy operations are done on the server. Easy to deploy and update.
  • Applets: small Java programs downloaded with a web page and run in the browser’s JVM, giving a richer user interface; they need the Java plug-in and a security policy.
  • Application clients (thick clients): stand-alone Java programs (Swing/AWT or command line) running on the client machine in an application client container; they can access EJBs directly via RMI-IIOP and use JNDI lookup, or call servlets over HTTP.
  • JavaBeans component architecture on the client side to manage data flow between client and server components.
  • Other clients: web service clients (SOAP/REST), non-Java clients via CORBA/web services, and messaging clients using JMS.

Server-side components they interact with: web components (servlets, JSP) and business components (session beans, entity beans, message-driven beans).

Q4 – Challenges in enterprise application development

  • Programmer productivity: combining many technologies quickly while meeting deadlines.
  • Response to demand / scalability: handling many concurrent users and growing load.
  • Integration with existing systems: connecting with legacy systems, ERP and different databases.
  • Freedom to choose servers, tools and components without vendor lock-in.
  • Maintaining security across distributed tiers and the internet.
  • Reliability, availability and performance: 24×7 operation, fault tolerance, load balancing.
  • Transaction management and data consistency across multiple resources.
  • Maintainability and changing business requirements.

J2EE addresses these with a standard multitier component model, container services (transactions, security, pooling), connectors and portability.

Q5 – Terms

J2EE Connector Architecture (JCA): a standard for connecting J2EE servers to heterogeneous Enterprise Information Systems (ERP, mainframes, legacy databases). Vendors provide resource adapters that plug into any compliant server, with system contracts for connection pooling, transaction management and security, and a Common Client Interface (CCI) for applications.

JMS API: the Java Message Service API lets components create, send, receive and read messages asynchronously and reliably. It supports point-to-point (queues) and publish/subscribe (topics) models; message-driven beans consume messages. It enables loosely coupled integration.

JDBC access: the JDBC API provides database-independent access to relational databases from Java: obtain a Connection (preferably from a DataSource via JNDI with connection pooling), execute SQL with Statement/PreparedStatement/CallableStatement, process ResultSet, and manage transactions (commit/rollback).

Q6 – J2SE Internationalization APIs in J2EE applications

Internationalisation (i18n) designs the application so it can be adapted to different languages and regions without code changes. J2SE APIs used in J2EE components:

  • Locale — identifies language and country (obtained in servlets from request.getLocale()).
  • ResourceBundle — loads locale-specific text from properties files (Messages_en_US, Messages_ur_PK).
  • NumberFormat, DateFormat, MessageFormat — format numbers, currency, dates and messages for the locale.
  • Collator for locale-sensitive sorting and Unicode/character encodings (UTF-8) for text.
// Messages_en_US.properties   ->  greeting=Welcome   total=Total amount
// Messages_ur_PK.properties   ->  greeting=Khush aamdeed   total=Kul raqam

import java.text.*;
import java.util.*;
import javax.servlet.http.*;
import java.io.*;

public class WelcomeServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse res)
            throws IOException {
        Locale locale = req.getLocale();              // from Accept-Language header
        ResourceBundle msgs = ResourceBundle.getBundle("Messages", locale);

        NumberFormat money = NumberFormat.getCurrencyInstance(locale);
        DateFormat   date  = DateFormat.getDateInstance(DateFormat.LONG, locale);
        String text = MessageFormat.format("{0}: {1}",
                          msgs.getString("total"), money.format(12500.75));

        res.setContentType("text/html; charset=UTF-8");
        PrintWriter out = res.getWriter();
        out.println("<h2>" + msgs.getString("greeting") + "</h2>");
        out.println("<p>" + date.format(new Date()) + "</p>");
        out.println("<p>" + text + "</p>");
    }
}

Q7 – Security threats and authentication mechanism

Threats to enterprise applications: unauthorised access and identity theft; eavesdropping on data in transit; tampering with data or requests; SQL injection and cross-site scripting; session hijacking; denial-of-service attacks; insider misuse; repudiation (users denying actions).

Authentication mechanisms in J2EE web applications (configured in web.xml <login-config>):

  • HTTP Basic: browser dialog; credentials sent Base64-encoded — use with SSL.
  • Form-based: custom login page posting j_username and j_password to j_security_check.
  • Digest: password sent as a hash.
  • Client certificate (HTTPS mutual authentication): client proves identity with an X.509 certificate.
Browser            Web container (Servlet/JSP)        Security realm (users/roles)
     |  1 request /secure/page  |                                   |
     |------------------------->|                                   |
     |  2 login form / 401      |                                   |
     |<-------------------------|                                   |
     |  3 username + password   |                                   |
     |------------------------->| 4 verify credentials              |
     |                          |---------------------------------->|
     |                          |<--------- 5 valid, roles ---------|
     |                          | 6 check role in web.xml           |
     |                          |   <security-constraint>           |
     |  7 protected resource    |                                   |
     |<-------------------------|   (session created, user known)   |

Steps: the client requests a protected resource; the container sees the security constraint and asks for credentials; the user submits them; the container verifies them against the security realm (users, groups, roles); if valid and the user’s role is allowed, access is granted and the identity is propagated to EJBs; otherwise an error page is returned.

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.