All Question paper with solution mean Bachelorexam.com

(Aktu Btech ) Web Technology Important Unit-5 Servlets and Javva Server Pages (JSP)

Use Aktu Btech Quantum Notes to deepen your understanding of web technology. You can improve your exam preparation with the help of these priceless commonly asked questions. Begin now to follow the route to success! Unit-5 Servlets and Javva Server Pages (JSP)

Dudes 🤔.. You want more useful details regarding this subject. Please keep in mind this as well.

Important Questions For Web Technology:
*Quantum               *B.tech-Syllabus
*Circulars                *B.tech AKTU RESULT
* Btech 3rd Year     * Aktu Solved Question Paper

Q1. What is servlet ? Explain its life cycle. Give its characteristics.

Ans. Servlet: 

  • 1. Servlets are simple Java programs that run on the servers.
  • 2. Servlets are most commonly used with HTTP. So, servlets are also called as HTTP servlet. 
  • 3. Servlet can process and store the data submitted by an HTML. 
  • 4. Servlets form. are useful for providing the dynamic contents. 

Life cycle of Servlet: 

What is servlet ? Explain its life cycle. Give its characteristics. Web Technology

Stages of the Servlet life cycle: 

  • 1. Loading a Servlet: 
    • a. The first stage of the Servlet life cycle involves loading and initializing the Servlet by the Servlet container. 
    • b. The Servlet container performs two operations in this stage :
      • i. Loading: Loads the Servlet class.
      • ii. Instantiation: Creates an instance of the Servlet. To create a new instance of the Servlet, the container uses the no argument constructor.
  • 2. Initializing a Servlet: 
    • a. The Servlet container initializes the instantiated Servlet object after the Servlet is successfully instantiated.
    • b. The container invokes the Servlet.init(ServletConfig) function, which takes a ServletConfig object reference as an argument, to initialize the Servlet object.
  • 3. Handling request: 
    • a. After initialization, the Servlet instance is ready to serve the client requests. 
    • b. The Servlet container performs the following operations when the Servlet instance is located to service a request: 
      • i. It creates the ServletRequest and ServletResponse objects.
      • ii. After creating the request and response objects it invokes the Servlet.service(ServletRequest, ServletResponse) method by passing the request and response objects. 
  • 4. Destroying a Servlet: 
    • a. When a Servlet container decides to destroy the Servlet, it performs the following operations, 
      • i. It allows all the threads currently running in the service method of the Servlet instance to complete their jobs and get released. 
      • ii. After currently running threads have completed their jobs, the Servlet container calls the destroy() method on the Servlet instance.a. When a Servlet container decides to destroy the Servlet, it performs the following operations, 
    • b. After the destroy() method is executed, the Servlet container releases all the references of this Servlet instance so that it becomes eligible for garbage collection.

Characteristics of servlet: 

  • 1. Servlet operates on input data that is encapsulated in a request object. 
  • 2. Servlet responds to a query with data encapsulated in a response object.
  • 3. Servlet can call EJB components to perform business logie functions. 
  • 4. Servlet can call JSPs to perform page layout functions.
  • 5. Servlet can call other servlets.

Q2. Explain how servlet works. 

Ans.

  • 1. The servlet container loads and deploys all of the servlets when the web server first starts.
  • 2. The servlet container provides an object called a ServletContext that serves as an interface and specifies the range of methods a servlet can use to interact with it.
  • 3. The servlet container creates an instance of the servlet class when the servlet has been loaded. The init() method of every newly created servlet is called.
  • 4. On a specific port, the client (user’s browser) sends an HTTP request to the web server.
  • 5. The HttpServlet Request and HttpServletResponse objects are then created by the servlet container.
  • 6. The HttpServletResponse object enables us to modify the http response before delivering it to the client and the HttpServletRequest object gives us access to the request information.
  • 7. For each client request, the servlet container creates a new thread and calls the service) function.
  • 8. Depending on the type of request, the service() function routes the request to the appropriate handler method.
Explain how servlet works. Web Technology
  • 9. When servlet container shuts down, it unloads all the servlets and calls destroy) method for each initialized servlets. 

Q3. Write short notes on session tracking with HttpSession. 

Ans.

  • 1. The HttpSession object is used for session tracking. 
  • 2. A session contains information specific to a particular user across the whole application.
  • 3. When a user enters into a website (or an online application) for the first time HttpSession is obtained via request.getSession(), the user is given a unique ID to identify his session. This unique ID can be stored into a cookie or in a request parametter. 
Write short notes on session tracking with HttpSession. Web Technology

The HttpServletRequest interface provides two methods to get the object of HttpSession: 

  • 1. public HttpSession getSession(): It returns the current session associated with session this request, or if the request does not have a session, creates one. 
  • 2. public HttpSession getSession(boolean create): It returns the current It returns the HttpSession associated with this request or, if there is no current session and create is true, returns a new session. 

Commonly used methods of HttpSession interface are: 

  • 1. public String get(d): It returns a string containing the unique identifier value. 
  • 2. public long getCreationTime): It returns the time when this session was created, measured in milliseconds. 
  • 3. public long getLastAccessedTime (): It returns the last time the client sent a request associated with this session. 
  • 4. public void invalidate(): It invalidates this session then unbinds any objects bound to it.

Q4. What do you mean by JSP? Explain the architecture of JSP. How JSP provides better performance? 

Ans.

  • 1. Java Server Pages (JSP) is a technology that helps software developers to create dynamically generated web pages based on HTML, XML or other document types. 
  • 2. JSP supports both scripting and element based allows dynamic content, and developers to create their own tag libraries. 
  • 3. JSP pages are compiled for efficient server processing. 
  • 4. JSP is platform independent. So, it can be without easily upgraded or switched affecting JSP based applications.  

JSP architecture: 

  • 1. Java Server Pages are part of a 3-tier architecture. 
  • 2. A server (application or web server) supports the Java Server Pages. 
  • 3 This server will act as a mediator between the client browser and a database. 
  • 4. The following diagram shows the JSP architecture: 
What do you mean by JSP? Explain the architecture of JSP. How JSP provides better performance? Web Technology
  • a. The user goes to a JSP page and makes the request via internet in web browser.  
  • b. The JSP request is sent to the web server.
  • c. Web server accepts the requested jsp file and passes the JSP file to the JSP Servlet Engine.
  • d. The JSP file is parsed if it has been called for the first time; otherwise, a servlet is created. The JSP file must then be converted into a servlet as the next step. The resulting servlet output is transmitted from the web server to the user’s web browser across the Internet.
  • e. Now in last step, HTML results are displayed on the user’s web browser. 

JSP provides better performance: JSP allows to embed the Java code directly in the HTMLfile and generates the contents dynamically. This helps to enhance the performance of JSP.  


Q5. Explain in detail the Tomcat server. 

Ans.

  • 1. Tomcat is a web server and servlet container that is used to deploy and serve Java web application. 
  • 2. Tomcat server is a Java-capable HTTP server, which could execute special Java programs known as”Java servlet” and “Java Server Pages”. 
  • 3. Tomcat can operate as a standalone web server. 
  • 4. It can operate as an out-of-process servlet container for some web such as Apache. Servers,
  • 5. For other web servers, such as IIS (Internet Information Services), it can operate as an in-process servlet container.  
  • 6. Tomcat server runs on a specific TCP post from a specific IP address.
  • 7. The default TCP port number for HTTP protocol is 80, which is used for the production HTTP server.
  • 8. To test HTTP server, we can choose any unused port number between 1024 and 65535. 
  • 9. There are two important environment variables to set before running Tomcat:
    • a. Set CATALINA_HOME to the root of Tomcat directory.
    • b. Set JAVA_HOME to the root directory of Java JDK or JRE.  

Q6. Explain implicit objects availble in JSP with example.  

Ans. Different types of implicit objects in JSP are: 

  • 1. Application object: The application object holds a reference to the instance of a class that implements the javax.servlet and has an application scope. interface for the ServletContext that represents the application.
  • 2. Config object: 
    • a. The config object has a page scope. This object implements the javax.servlet. ServletConfig interface.
    • b. The config object gives access to configuration data for initializing the JSP. 
  • 3. Session object: 
    • a. HttpSession class represents the current session of the JSP page.
    • b. It represents the scope of this session, and it is useful in order to keep attributes and values and providing them in different JSP pages of same application. 
  • 4. Out object:
    • a. The out object also has a page scope. Out object is an instance of javax.servlet.jsp.JspWriter class.
    • b. By using this object the text is added to the response message body. 
  • 5. Page object:
    • a. Page object is an instance of java.lang Object class.
    • b. The page object is a reference to the current instance of the JSP. 

Example:

Explain implicit objects availble in JSP with example. Web Technology
Explain implicit objects availble in JSP with example. 
bachelor exam preparation all question paper with solution important questions with solution

Web Technology Btech Quantum PDF, Syllabus, Important Questions

LabelLink
Subject SyllabusSyllabus
Short QuestionsShort-question
Question paper – 2021-222021-22

Web Technology Quantum PDF | AKTU Quantum PDF:

Quantum SeriesLinks
Quantum -2022-232022-23

AKTU Important Links | Btech Syllabus

Link NameLinks
Btech AKTU CircularsLinks
Btech AKTU SyllabusLinks
Btech AKTU Student DashboardStudent Dashboard
AKTU RESULT (One VIew)Student Result

Important Links-Btech (AKTU)

LabelLinks
Btech InformationInfo Link
Btech BranchLINK
Quantum-PageLink

Leave a Comment