Hi All,
I am trying to run a simple program which uses Server-Side Includes but some how it is not calling
servlet program from .shtml file. Please find below a sample code .shtml and servlet code.
Times.shtml
-----------------------------------------------------------------
HTML>
<HEAD><TITLE>Times !!</TITLE></HEAD>
<BODY>
The current time here is:
<SERVLET CODE=CurrentTime>
</SERVLET>
<P>
The current time in London is:
<SERVET CODE=CurrentTime>
<PARAM NAME=zone VALUE=GMT>
</SERVLET>
<P>
The current time in Silicon valley is:
<SERVET CODE=CurrentTime>
<PARAM NAME=zone VALUE=PST>
</SERVLET>
<P>
</BODY>
</HTML>
-----------------------------------------------------------------
CurrentTime.java code
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CurrentTime extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
//PrintWriter out = res.getWriter();
PrintWriter out = new PrintWriter(res.getOutputStream(), true);
Date date = new Date();
DateFormat df = DateFormat.getInstance();
String zone = req.getParameter("zone");
if (zone != null) {
TimeZone tz = TimeZone.getTimeZone(zone);
df.setTimeZone(tz);
}
out.println(df.format(date));
}
-----------------------------------------------------------------
I tried to run
test servlet program by entring following values in the browser and it seems to be working OK.
http://localhost:8080/servlet/CurrentTime?zone=EST I also tested for GMT and PST and values appear to be correct but somehow my .shtml file either does not call this servlet or servlet does not respond to this call.
I am using jswdk-1.0.1 on win98 machine.
Thanks in advance !!
Regards,
Milind