You are on page 1of 5

Java Server Pages (JSP) & Servlets

Web Development
Introduction – Serving Static Pages
HTTP Request
GET
…..
…..

<HTML>
<HEAD>
<HTML>
</HEAD>
<HEAD>
<HTML>
</HEAD>
<HEAD>
<BODY></HEAD>
HTTP Response ……..
<BODY>
</BODY>
……..
<BODY>
</HTML>
</BODY>
……..
<HTML> </HTML>
</BODY>
<HEAD> </HTML>
</HEAD>
Client Web Server
<BODY>
……..
</BODY>
</HTML>

The web server gets the


A web browser lets user request, finds the resource,
request a resource and returns it to user.
(HTML page, picture, sound)
But what if you want Dynamic Content &
Ability to Save Data on the Server?

Web Server
parameters

HTTP header info <HTML>


<HEAD>
<HTML> </HEAD>
<HEAD>
</HEAD>

<BODY>
web server <BODY>
…….. helper
</BODY>
……..
</BODY>
app </HTML> app
</HTML>

• Need some kind of “helper” app that can work with the server
• Helper apps is what does the work of generating dynamic content
• Helper app in the web server can be:
– JSP / Servlets (Java)
– ASP (Microsoft)
– “CGI” Program (Perl, Python, C)
– PHP
JSP = HTML + Java (sort of)
<HTML>
Class TimeIs {
<BODY>
void check() {
The current time is:
x = new Date();
XX:XX
}
</BODY>
}
</HTML>

<HTML>
<BODY>
The current time is:
<%= new
java.util.Date() %>
</BODY>
</HTML>

• Like putting Java into an HTML page (sort of).


• More like putting in labels that call real Java methods rather than embedding
actual Java code into the page.
Deploying and Running Servlet
1. Write Servlet
2. Create a Deployment Descriptor (DD)
3. Compile servlet
4. Copy compiled *.class file and DD to
appropriate directories
5. Launch browser and type in URL

You might also like