Professional Documents
Culture Documents
Server Page
1
Agenda
• Why we need JSP
• How JSP works
• Benefits of JSP
• Setting up your environment for JSP
• A simple example
Server restarted
Page modified
compiled
</BODY>
</HTML>
<BODY>
<H1>JSP Declarations</H1>
</BODY>
39
</HTML>
Java Server Page Web Programming – IU – IT – 2014
JSP Declarations: Result
• After 15 total visits by an arbitrary number
of different clients
• First access
• Subsequent
accesses
</BODY>
</HTML>
</CENTER>
</BODY>
</HTML>
<%!
// Note lack of try/catch for NumberFormatException
private double toDouble(String value) {
return(Double.valueOf(value).doubleValue());
}
%>
70 Java Server Page Web Programming – IU – IT – 2014
Error Pages: Example
(ComputeSpeed.jsp Cont.)
<%
double furlongs =
toDouble(request.getParameter("furlongs"));
double fortnights =
toDouble(request.getParameter("fortnights"));
double speed = furlongs/fortnights;
%>
<UL>
<LI>Distance: <%= furlongs %> furlongs.
<LI>Time: <%= fortnights %> fortnights.
<LI>Speed: <%= speed %> furlongs per fortnight.
</UL>
...