JSP/Servlet constructor problem


Web tier: servlets, JSP, Web frameworks: JSP/Servlet constructor problem

  1. JSP/Servlet constructor problem (4 messages)

    I am trying to create a .jsp file that instanciates a servlet I've created. If I have a constructor defined in the servlet, I get an error in my log saying that it is an undefined constructor. It works fine w/o the constructor. Anyone have any idea why this happens? If it matters, I'm using IBM WAS to serve these pages. Any help if GREATLY appreciated.

    Threaded Messages (4)

  2. JSP/Servlet constructor problem[ Go to top ]

    You dont need to call the servlet directly from
    the jsp; e.g servlet = new HttpServlet();
    Is this what you are doing??

    You can do an include like this:

    <jsp:forward page="controller" />

    "controller" is a servlet that is registered in the web.xml
    file.The web server associates the name controller with the
    file ControllerServlet.class.

    The Servlet container will automatically instantiate
    the Servlet if it is not already loaded. The example I have given forwards the request and does not wait for a reply.
    the response given by controller will be routed to the browser.

    To include the response from your servlet in the jsp output
    use an include

    <jsp:include page="controller" flush="true" />

    I hope this helps.

  3. Forgive my ignorance, I'm pretty new to this. I wasn't using any xml. As you said, I was simply doing this :
    MyServlet myservlet = new MyServlet(parmlist);
    and it doesn't like it but if I do :
    MyServlet myservlet = new MyServlet();
    and remove the constructors from MyServlet it works fine.
    I'm confused by the xml information you gave to me. Is there a way to do this w/o xml? Thanks again.
  4. JSP/Servlet constructor problem[ Go to top ]

    If the webserver you are using implements the j2ee spec
    then you should have the following files somewhere.


    server.xml is used to define your directories and
    web.xml allows you to define your servlets.
    If you want to get started download the jakarta web server
    from apache. You can run it as a standalone web-server.

    www.apache.com or org or something like that.

  5. JSP/Servlet constructor problem[ Go to top ]

    ps. just constructing the servlet with a new Servlet()
    wont help as the Servlet framework has to do this not your
    jsp. Try looking at the servlet tutorial at the sun site.
    The jrun product from allaire comes with some really good
    pdf docs that explain the j2ee architecture.