The moose likes Servlets and the fly likes Problem with SHTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem with SHTML" Watch "Problem with SHTML" New topic

Problem with SHTML

Manalia Rathi

Joined: Nov 22, 2000
Posts: 4
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">
<title>Server Sider Include Example</title>

<h1>The plain Time is....</h1>
<h1>The PST Time is...............</h1>
<SERVLET code=DateSsi >

<h1>The GMT Time is....</h1>
<h1>The CET Time is....</h1>

The servlet code is
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 {

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);

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......
I agree. Here's the link:
subject: Problem with SHTML
It's not a secret anymore!