SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need help with Jigsaw and SSI

    Hi All,

    I am new to Web Development. I normally do Java Development but right now am involved in a JSP, Servlet and HTML project. I have been comming along fine in figuring everything out up to now but this is a real stumping problem.

    I am trying to work a SSI example and I am having a problem with the ssi tag used on the Jigsaw server

    I have an index.shtml page which includes the following tag to display the hit count from the ncount1 servlet.

    <!--#servlet name="ncount1" code="servlet/ncount1" -->

    However, I get the following exception when I open the index.shtml page.

    Exception in thread "servlet-runner:1" java.lang.NullPointerException at org.w3c.jigsaw.servlet.JigsawHttpServletResponse.flushStream(JigsawHttpServletResponse.java:649)

    I have googled for this exception and have found nothing of use.

    I know the servlet works correctly, because If I change the contentType to text/html, have the servlet parse it's own html page, then point the browser directly to the servlet instead of my index.shtml page, the html page the servlet parses displays fine including the count value returned from the cCountObject.

    I also looked on the W3C Jigsaw site and verified that the tag I am using is correct. Unfortunatly, there doesn't seem to be a forum on the Jigsaw site unless it is on the convoluted main W3C site in which case I am sure you would have to be a W3C member to get to it anyway.

    My test servlet code is below along with the class it calls.

    -----------------------------------------------------------------------------------------


    import javax.servlet.*;
    import java.io.*;

    public class ncount1 extends GenericServlet{
    private cCountObject Counter;
    public void init(ServletConfig _config) throws ServletException{
    super.init();
    Counter = new cCountObject();
    }

    public void service(ServletRequest _req, ServletResponse _res)
    throws ServletException, IOException{
    Counter.increment();
    _res.setContentType("text/plain");
    PrintWriter Out = _res.getWriter();
    Out.println(Counter.getHit());
    Out.flush();
    }

    public String getServletInfo(){
    return "nCount Hit Servlet v1";
    }
    }



    --------------------------------------------------------------------------------------------



    import java.util.Date;

    public class cCountObject {
    private int hitcount;
    private String lastIP;
    private String lastDate;

    public cCountObject(){
    hitcount = 0;
    lastIP = null;
    }

    public void increment(String _IP){
    if(lastIP != null && lastIP.compareTo(_IP) != 0){
    hitcount++;
    lastIP = _IP;
    lastDate = new Date().toString();
    }
    }

    public void increment(){
    hitcount++;
    lastDate = new Date().toString();
    }

    public int getHit(){
    return hitcount;
    }
    }


    Any help will be greatfully appreciated!

    Thanks,

    L

  2. #2
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can anyone verify.

    I have googled for the past two days and finally found something on a Apache forum which may apply here as well. On the Apache site someone said that the <!=#servlet name="" code=""> tag was removed from use (on apache servers?) when the JSP 1.0 standard came out because the

    <jsp:include page="{ relativeURL | <%= expression %>}" flush="true" />

    tag performs the same basic functionality. I am going to test it when I get home from work today, but I was wondering if anyone can verify this for me?

    Thanks,

    L


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •