0% found this document useful (0 votes)
5 views

Day3 Notes

servlet

Uploaded by

souparna17
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Day3 Notes

servlet

Uploaded by

souparna17
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Types of applications

1. single user application(J2SE)--→ the application, installed on a machine,and can be


used only on that machine
2. Web application(J2EE)-→ It is a 3 tier application, deployed on the server and used on
the client machine, It returns the response in HTML format. these are usually used in
B2C communication(business to Client) communication
3. Mobile Application(J2ME)--→ the application which works on mobile, is called as mobile
application
4. Web services-→It is a application which is deployed on server, and returns response in
the form of JSON. It is mostly used in B2B(business to business) communication

The web server we are using is tomcat, by default it runs on port 8080

To use tomacat

1. install tomcat on your machine and unzip the file


then do the following setting
1. set JAVA_HOME = C:\Program Files\Java\jdk-11.0.10
2. set path = %JAVA_HOME%\bin
3. set TOMCAT_HOME= E:\apache-tomcat-9.0.76\apache-tomcat-9.0.76

In linux for setting

1. open the file .bashrc, and in this file

export TOMCAT_HOME= E:\apache-tomcat-9.0.76\apache-tomcat-9.0.76

export JAVA_HOME = C:\Program Files\Java\jdk-11.0.10

export path = %JAVA_HOME%\bin

To start the tomcat

1. open the command prompt, and change the folder to tomcat bin

form tomcat conf folder

2. open tomcat_users.xml file

and add the following lines into the file

<role rolename="manager-gui"/>

<user username="manager" password="" roles="manager-gui"/>

3. and then start the server

e:\.....tpmcat..\bin>startup.bat

4. click on Manager GUI


username=manager
password=””
5. to stop the server
e:\tomcat….\bin>shutdown
In tomcat webapp folder works like web container

http -→it is a protocol, that is set of rules of communication between 2 machines


It is a stateless protocol

The url has following parts

When the data is transferred between client and server, the it uses request and
response object

To transfer data from client to server-→ we use request object


To transfer data from server to client-→ we use response object
War file(web archive)
When web application is deployed on the server, the file is war file
Structure of war file

To create a servlet, create a class and extend it from HttpServlet


1. when servlet receives request 1, then it gets loaded in the RAM, request and
response objects get created, and then init method gets called, then service
method handles the request, service method receives 2 parameter ServlerRequest,
ServletResponse
2. req2-→ request and response object will get created, and service method will
handle request. , All further requests will be handled by service method
3. when you will undeploy the servlet, or if you shutdown the server, then destroy
method will get called.
4. In the life time of servlet init and destroy method gets called only once

You might also like