Servlets are Java-based web components used for developing web applications. They can handle various types of HTTP requests and generate dynamic web content.
It defines a simple servlet that responds to GET requests by sending an HTML page with a welcome message. It also includes lifecycle methods and demonstrates when these methods are invoked during the servlet's lifecycle.
|=> webapp(public area) |=> index.html(default landing page)
request(static request) :: http://localhost:9999/SecondServletApp/
response(static response) :: copy of index.html will be sent
"Student Registration Page" serves as a user-friendly web interface for students to input their registration information, including name, address, and mobile number. Upon submitting the form, the data is sent to a server for processing, which is typically handled by a server-side script or servlet.
This Java Servlet, when invoked through an HTTP request, accepts student details such as name, age, and course. It processes this data and then uses JDBC to establish a connection with a MySQL database. Subsequently, it inserts the student's information into the database. Finally, it returns a web page to acknowledge the successful data insertion or any potential errors.
a. browser sends the request(either for static or for dynamic)
b. server traps the request and identifiers whether the request is for a. static resource b. dynamic resoure
c. If the request is for static resource,then server only will take the copy of that resource and sends the copy of the resource as the response to the browser.
d. If the request is for static resource and if the resource is not available then server will generate the response as "404-page not found".
e. If the request is for dynamic resource, then server will identify for that request which .java code should be executed.
f. To identify for a particular resource, which java file server will use "web.xml/annotation".
g. Once the required java code is available then server will handover the control to "container".
i. Container will execute the java code based on its "LifeCycle-Actions".
a. Go to the following link https://tomcat.apache.org/download-90.cgi
b. click on 32-bit/64-bit Windows Service Installer (pgp, sha512)
c. Once the download starts, double click and install the set up file
d. During the installation it will ask for password supply the password as "root123" and change the http-port-no :: 9999.
e. Once the installation is ready, just go to C:\tomcat9.0\bin\tomcat9.exe
f. Double click on that file and check the status of te server(
++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
- Click on Server tab
- Select Apache folder(tomcat9.0)
- Click on next
- Click on finsih(make sure the server tab is filled with tomcat file)
- Select tomcat9.0 file and start the server(check in conosle for the information like server startup)
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++
- Create dynamic webproject and choose runtime environment as tomcat9.0
- choose servlet version 3.1
- Click on next
- Type the userdefined servlet name as per your choice[Our class will be made as a parent for HttpServlet].
- Click on finsh
a. Servlet Loading
b. Servlet Instantiation
c. Servlet Initialization(init())
d. Request Processing(doXXXX(request,response)
e. Servlet De-Instantiation(destroy())