Results 1 to 7 of 7
  1. #1
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,800
    Rep Power
    25

    Default [SOLVED] Problem using jsp:forward to a servlet

    I've just started working with Tomcat (version 5.5) and am having the following problem;

    I have a jsp page (..\webapps\Norms\jsp\process.jsp) with the following forward statement.
    <jsp:forward page="/servlet/DBHandler"/>

    The app is started with the URL: http://127.0.0.1:8080/Norms/forms/register.html

    The register.html file (...\webapps\Norms\forms\register.html) has the following <form:
    <form action="/Norms/jsp/forms/process.jsp" method=post>

    I have a servlet program: DBHandler.java (not in a package) that I've compiled and put copies of the class file in many locations in a folder called servlet.

    I get a 404 error message when I load the html file, submit the form to the jsp page and it tries to forward to the servlet.

    Estado HTTP 404 - /Norms/servlet/DBHandler (in Spanish)

    Do I need entries in any xml files or in a tld file or where do I put the class file so that the jsp engine will find it.

    Thanks,
    Norm

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,800
    Rep Power
    25

    Default

    I got it to work by puttiing the program DBHandler in package: forms and added the following to the web.xml file in Norms/WEB-INF/
    Java Code:
        <servlet>
          <servlet-name>          DBHandler      </servlet-name>
          <servlet-class>         forms.DBHandler      </servlet-class>
        </servlet>
    
    
        <servlet-mapping>
            <servlet-name>        DBHandler          </servlet-name>
            <url-pattern>        /servlet/DBHandler  </url-pattern>
        </servlet-mapping>
    The path to the class file is:
    "C:\Archivos de programa\Apache Software Foundation\Tomcat 5.5\webapps\Norms\WEB-INF\classes\forms\DBHandler.class"
    Last edited by Norm; 12-16-2008 at 08:01 PM.

  3. #3
    andyjwang is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default Can you send me the whole folder structure please?

    Hi Norm,

    I have been struggling with the error message, below, with the
    <jsp:forward page="/servlet/DBHandler"/> in process.jsp.

    java.lang.NoClassDefFoundError: forms/DBHandler (wrong name: DBHandler)

    I will appreciate that you post the whole structure of the register jsp application for me to follow.

    Or zip the folder Norm for me to download?

    Thanks a lot.

    Andy Wang

  4. #4
    andyjwang is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default Never mind, I got it now.

    Hello,

    Never mind, I got it now.

    <jsp:forward page="/servlet/DBHandler"/> in process.jsp.
    is looking for the url mapping for /servlet/DBHandler
    I had it set as seen below in web.xml.

    <servlet>
    <servlet-name> DBHandler </servlet-name>
    <servlet-class> DBHandler </servlet-class>
    </servlet>


    <servlet-mapping>
    <servlet-name> DBHandler </servlet-name>
    <url-pattern> /servlet/DBHandler </url-pattern>
    </servlet-mapping>

    So it is looking for the DBHandler servlet-name that is the DBHandler class.
    My tree looks like this:

    I:\forms>dir /s
    Volume in drive I is Windows7
    Volume Serial Number is 5C4E-C9D6

    Directory of I:\forms

    04/26/2009 09:50 PM <DIR> .
    04/26/2009 09:50 PM <DIR> ..
    04/26/2009 09:44 PM 583 process.jsp
    04/24/2009 10:18 PM 3,467 retry.jsp
    04/24/2009 10:18 PM 1,537 success.jsp
    04/25/2009 06:44 PM 2,493 user_registration_form.jsp
    04/26/2009 09:50 PM <DIR> WEB-INF
    4 File(s) 8,080 bytes

    Directory of I:\forms\WEB-INF

    04/26/2009 09:50 PM <DIR> .
    04/26/2009 09:50 PM <DIR> ..
    04/26/2009 09:50 PM <DIR> classes
    04/26/2009 09:18 PM 2,095 web.xml
    1 File(s) 2,095 bytes

    Directory of I:\forms\WEB-INF\classes

    04/26/2009 09:50 PM <DIR> .
    04/26/2009 09:50 PM <DIR> ..
    04/26/2009 06:53 PM 1,552 DBHandler.class
    04/26/2009 09:50 PM <DIR> foo
    04/24/2009 10:18 PM 54 forms.properties
    2 File(s) 1,606 bytes

    Directory of I:\forms\WEB-INF\classes\foo

    04/26/2009 09:50 PM <DIR> .
    04/26/2009 09:50 PM <DIR> ..
    04/26/2009 06:48 PM 4,294 FormBean.class
    1 File(s) 4,294 bytes

    Total Files Listed:
    8 File(s) 16,075 bytes
    11 Dir(s) 143,770,759,168 bytes free

    I:\forms>

    My invoking url is:
    /forms/user_registration_form.jsp

  5. #5
    bumbasan's Avatar
    bumbasan is offline Member
    Join Date
    Apr 2009
    Posts
    1
    Rep Power
    0

    Default

    How to start to trade in video technics?
    Who can that advise?
    What it is necessary for this purpose?
    Advise how to begin.

  6. #6
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default

    Bumbasan... does your question have to with Java? Please be more explicit in your request.

    Thanks,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  7. #7
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default In English please...

    SMSslon: Please edit your post and rephrase in English. The official language in this forum is English.

    Thanks,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. I need a back and forward code
    By Jaymz in forum New To Java
    Replies: 9
    Last Post: 10-13-2008, 12:50 AM
  2. Back-Forward Simulation using stacks(java)
    By MarKus in forum New To Java
    Replies: 3
    Last Post: 09-10-2008, 02:47 PM
  3. Replies: 5
    Last Post: 07-29-2008, 03:13 PM
  4. jsp:forward action
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-24-2007, 11:04 AM
  5. Problem in Servlet with JDBC
    By *New Programer* in forum Java Servlet
    Replies: 2
    Last Post: 12-20-2007, 10:15 AM

Posting Permissions

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