Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-09-2008, 06:52 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-15-2008, 06:39 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
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/
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-26-2009, 04:10 AM
Member
 
Join Date: Apr 2009
Posts: 2
Rep Power: 0
andyjwang is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-27-2009, 08:05 AM
Member
 
Join Date: Apr 2009
Posts: 2
Rep Power: 0
andyjwang is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-27-2009, 04:34 PM
bumbasan's Avatar
Member
 
Join Date: Apr 2009
Posts: 1
Rep Power: 0
bumbasan is on a distinguished road
Default
How to start to trade in video technics?
Who can that advise?
What it is necessary for this purpose?
Advise how to begin.
__________________
bumbasan
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-27-2009, 10:46 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-27-2009, 10:49 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need a back and forward code Jaymz New To Java 9 10-13-2008 12:50 AM
Back-Forward Simulation using stacks(java) MarKus New To Java 3 09-10-2008 02:47 PM
<jsp:include> Vs <%@include> Vs <jsp:forward> Vs RequestDispatcher .forward/includeVs freddieMaize Java Servlet 5 07-29-2008 03:13 PM
jsp:forward action Java Tip Java Tips 0 12-24-2007 11:04 AM
Problem in Servlet with JDBC *New Programer* Java Servlet 2 12-20-2007 10:15 AM


All times are GMT +2. The time now is 09:37 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org