Testing SSI for servlet problem

M

moonhk

How to testing SSI for servlet ? I am using Apache Tomcat/5.5.17.

Output without date and time.

as below

The current time here is:
The current time in London is:

And the current time in New York is:



below is Book coding , 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:
<SERVLET CODE=CurrentTime>
<PARAM NAME=zone VALUE=GMT>
</SERVLET>
<P>
And the current time in New York is:
<SERVLET CODE=CurrentTime>
<PARAM NAME=zone VALUE=EST>
</SERVLET>
<P>
</BODY>
</HTML>

Servlet

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top