0% found this document useful (0 votes)
34 views10 pages

Its - Isdv Lab1-Servlet: Objective

1) The purpose of this lab is to learn implementing client-server applications using Java servlets. 2) The document describes tasks to deploy a static web page on a server, change the context path, and develop a dynamic web page using a servlet. 3) Students are instructed to complete tasks that include creating Java web projects, adding HTML files, and configuring servlets and web.xml files to display web pages dynamically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views10 pages

Its - Isdv Lab1-Servlet: Objective

1) The purpose of this lab is to learn implementing client-server applications using Java servlets. 2) The document describes tasks to deploy a static web page on a server, change the context path, and develop a dynamic web page using a servlet. 3) Students are instructed to complete tasks that include creating Java web projects, adding HTML files, and configuring servlets and web.xml files to display web pages dynamically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

ITS - ISDV

Lab1- Servlet
Objective
The purpose of this lab is to learn implementing a client-server application using Java servlets

Description
Task 1: deploying a static web page on the server
Today, your task is deploying a static Web page on GlassFish. For this purpose, do the following
steps:
1. Install Netbeans, if you already have not installed it. Click on the following link and then
select Java bundle
http://www.netbeans.org/downloads/
2. Run the netbeans and create a new project: File> New Project
3. Select Java Web category and Web Application project.

4. Define a name for your project, such as FirstServlet, then click on Next button.

Here, you should be able to see the server which is GlassFish. Context path is also
specified here as well.
5. Click on Finish.

6. Run it. You will see the index.jsp in the web browser in the following address.
http://localhost:8080/FirstServlet/

Task 2: Change the Context Path


1. In the above task, the context path was FirstServlet. In this task, you change the context
path to Hello and run the application again. The following url is opened.
http://localhost:8080/Hello/
2. Create a hello.html by right-clicking on Web Page>New>HTML

3. Name the html file hello.

4. Edit hello.html as demonstrated below:

5. The last step is to change web.xml. Double-click on web.xml in WEB-INF directory.


Then click on XML tab. Change the index.jsp to hello.html in <welcome-file> tag.

Now, run the project. You will see hello.html instead of index.jsp as a welcome page.
Note: Servlets are used to create the dynamic Web pages. Since, hello.html is a static web page,
you do not need to develop a servlets application.

Task 2: developing a dynamic web page HelloWorld


In this task, you develop a servlet to handle the users request. For this, do the following steps:
1. Create a hello servlet
a. Right-click on Source Packages. Select New>Servlet. Name it HelloServlet

b. Remove the comment in HelloServlet as shown below:

c. Add some html tags to the servlet. And run the application.
2. The next step is to edit web.xml. To do this, double-click on web.xml. Select Servlets
tab and change the URL pattern to hello2.html.

3. Testing: Open a browser and type http://localhost:8001/Hello/hello2.html. The response


is an html file generated by the servlets.

Notes

Java APIs: http://java.sun.com/j2se/1.5.0/docs/api/

Deliverables
When your program is complete, submit and show it to your instructor.

You might also like