I have a problem while making a simple SSI. I call a dateservlet in my SHTML to show different time zones. But the problem is that once I pass a parameter the time is set for that particular Zone and it does not change. That seems strange. Could anybody explain it ?
this example is from Orelliy's
Servlet book :
The code for SHTML is :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Server Sider Include Example</title>
</head>
<body>
<h1>The plain Time is....</h1>
<SERVLET CODE=DateSsi>
</SERVLET>
</p>
<h1>The PST Time is...............</h1>
<SERVLET code=DateSsi >
<PARAM NAME=zone VALUE="CET">
</SERVLET>
</P>
<P>
<h1>The GMT Time is....</h1>
<SERVLET CODE=DateSsi >
<PARAM NAME=zone VALUE="GMT">
</SERVLET>
</P>
<P>
<h1>The CET Time is....</h1>
<SERVLET CODE=DateSsi>
<PARAM NAME=zone VALUE="EST">
</SERVLET>
</P>
</body>
</html>
The servlet code is
import java.io.*;
import java.util.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DateSsi extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
Date dt = new Date();
DateFormat df=DateFormat.getInstance();
String zone1 = req.getParameter("zone");
if ( zone1 != null ) {
TimeZone tz= TimeZone.getTimeZone(zone1);
df.setTimeZone(tz);
}
out.println("the zone is" + zone1 + "<br><br>");
out.println("<br>The Time is :" + df.format(dt) + "......");
}
}
The output looks like this when I invoke the SHTML in JWS2.0
The plain Time is....
the zone isnull
The Time is :2000-11-22 10:05......
The PST Time is...............
the zone isCET
The Time is :2000-11-22 09:05......
The GMT Time is....
the zone isCET
The Time is :2000-11-22 09:05......
The CET Time is....
the zone isCET
The Time is :2000-11-22 09:05......