• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with SHTML

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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......
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic