File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Server-Side Includes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Server-Side Includes" Watch "Server-Side Includes" New topic

Server-Side Includes

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.
The current time here is:
<SERVLET CODE=CurrentTime>
The current time in London is:
<SERVET CODE=CurrentTime>
The current time in Silicon valley is:
<SERVET CODE=CurrentTime>
----------------------------------------------------------------- code
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);


I tried to run test servlet program by entring following values in the browser and it seems to be working OK.


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 !!


surya sadhu

Joined: Feb 16, 2004
Posts: 13
I think that example is from
<font color=red > Servlets by Jason Hunter</font>
In that book ,in first chapters itself he mentioned
that the servletrunner provided along with JSDK
(in your case jswk) won't support all the
functionalities like Servlet chaining , SSI etc.
So you better download java web server or some equivalent.
surya sadhu

Joined: Feb 16, 2004
Posts: 13
Please ignore the html tags
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2373

Milind, that Jason's code has caused same problem to me after abt 1 and 1/2 years.... i m crossing time towards back in a time machine...
Does so many days later, Tomcat 4.0.1 still can't solve this problem?
Muhammad Ashikuzzaman (Fahim)
Sun Certified Programmer for the Java� 2 Platform
--When you learn something, learn it by heart!

Ashik Uzzaman
Senior Software Engineer, TubeMogul, Emeryville, CA, USA.
Johnson David

Joined: May 22, 2005
Posts: 27
Hi friends ,

I spent so much of time on SSI includes , but i am unable to execute it . ...i am getting the same problem as . .milind .. . can somebody help us to get out of this problem , by giving an example or providing an URL

how to work with SSI includes in weblogic or tomcat ?

thanx in advance
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Keep in mind that this thread is 5 years old, you may be better off asking questions like these in a new thread.

I agree. Here's the link:
subject: Server-Side Includes
It's not a secret anymore!