java2db

Create and run a servlet example (Eclipse,GlassFish)



Servlet is a java based server side web technology to develop dynamic web resource programs . Basic requirements are given below to create and run a servlet example .

 

Softwares :
Java (Download).
GlassFish server (Download).
Eclipse (Download).
Jar files:
javax.servlet.jar (Download).
javax.servlet.jsp.jar (Download).
Source files :
welcomeServlet.class(servlet)
web.xml

 

create a servlet You can deploy the below Web application in any  java supported Web/Application server (Like Tomcat , JBoss, WebSphere , Jetty , Weblogic,….).

 

Create and run a servlet example Directory Structure : 

 

 

Create and run a servlet example Deployment : Right click on server , select Add and Remove , select the project and click finish button.

 

 

1. Web-client request comes to the Web-server , First it looks for the web application.If exists , it will search for url-pattern (/welcomeApp) in the web.xml from the WEB-INF folder.

2. Later it identifies the servlet-name (Logical Name) ,In our example it is ServletExe .

3. Next it checks for the exact match of the servlet-name (ServletExe) inside the <servlet> tag.

4. Next it checks the servlet-class (servletApp.welcomeServlet) .

5. Loads the servlet class  (welcomeServlet.class) from  WEB-INF/classes to the container.

6. The doGet() method will execute (see the Servlet Lifecycle).

7. Finally the response goes to the client window.

 

Create and run the servlet example Example code to create and run a servlet :

Create and run the servlet example welcomeServlet.java

Create and run the servlet example web.xml

 

 

Create and run a servlet example URL to Run the Application :

http://localhost:8080/welcomeServletApp/welcomeApp

Create and run the servlet example http           :-  The Hypertext Transfer Protocol

Create and run the servlet example localhost :- Host name (if the server is located in a remote machine , use the IP(Ex :192.164.2.3) address).

Create and run the servlet example 8080       :-  Port number of the server that can be hear the client requests.

Create and run the servlet example welcomeServletApp :- Deployed web application name.

Create and run the servlet example welcomeApp :- Url pattern of the servlet program (It is in web.xam).

 

 Create and run the servlet exampleExecution Result

 

 

 




Related Posts :

No related posts found!

Comments

  1. Palanikumar says:

    please upload very very basic and small project like jsp+mysql , spring+mysql, Struts+mysql and so on. am very proud of your work

   [will not be published]



^ <