aspose file tools*
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
Author

Server-Side Includes

Anonymous
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.
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

surya sadhu
Greenhorn

Joined: Feb 16, 2004
Posts: 13
HI
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
Greenhorn

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

Joined: Jul 05, 2001
Posts: 2370

Milind, that Jason's code has caused same problem to me after abt 1 and 1/2 years.... ...like 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 Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Johnson David
Greenhorn

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
Rancher

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.

Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Server-Side Includes