Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - cannot get my JSP to forward to database-handler servlet (innetbeans)

 
Thread Tools Search this Thread
Old 11-05-2009, 11:34 AM   #1
Default cannot get my JSP to forward to database-handler servlet (innetbeans)


I have a JSP that processes some html form (processForm.JSP) and then
forwards to a Java Servlelt that carries out some mysql transactions
to do error checking (under 'project->Source Packages' I have a new
package called 'foo', servlet is DBHandler.java)

processForm.jsp contains the following lines :-

<% if (formHandler.validate()) {
%>
jsp:forward page="/DBHandler" />


I have updated web.xml with the name and location of the DBHandler
(<servlet-class>foo.DBHandler</servlet-class>)

When I compile/deploy/run in netbeans - my web application falls over,
in firefox I get a very brief error (HTTP 404 - the requested resource
() is not available), I get nothing in the netbeans glassfish console.

I have placed some System.out.println to help me debug the sequence of
events, and I can see that DBHandler.java is never called

Can some one please point out what exactly should the syntax be for
forwarding from JSP->servlet (i.e. the JSP forward syntax), should
there be '/' or not?? does web.xml take care of the mapping from name -
> location??


any help appreciated


terry433iid@yahoo.com
  Reply With Quote
Old 11-05-2009, 01:01 PM   #2
MikisM
 
Posts: n/a
Default Re: cannot get my JSP to forward to database-handler servlet (innetbeans)
For starters: 'jsp:forward page="/DBHandler" />' should start with '<'
so you should have written like '<jsp:forward page="/DBHandler"/
>' (although I believe you just have'nt copied that symbol from you

code). Apart from that, all your jsp:forward syntax is correct.
From the error it would seem that your servlet is not accessible which
is caused by the wrong <servlet-mapping/> element for your servlet (I
guess). You should check it out. Just to be sure you could post
<servlet/> and <servlet-mapping/> contents from web.xml file of the
servete that is troubling you. I will be able to tell you more about
the problem when you do that.
And yes. web.xml is where you put all your servlet mappings. You can
google about the topic: there are plenty of articles, tutorials and
forums that will help you.


MikisM
  Reply With Quote
Old 11-06-2009, 02:56 AM   #3
Arne Vajhøj
 
Posts: n/a
Default Re: cannot get my JSP to forward to database-handler servlet (innetbeans)
wrote:
> I have a JSP that processes some html form (processForm.JSP) and then
> forwards to a Java Servlelt that carries out some mysql transactions
> to do error checking (under 'project->Source Packages' I have a new
> package called 'foo', servlet is DBHandler.java)
>
> processForm.jsp contains the following lines :-
>
> <% if (formHandler.validate()) {
> %>
> jsp:forward page="/DBHandler" />
>
>
> I have updated web.xml with the name and location of the DBHandler
> (<servlet-class>foo.DBHandler</servlet-class>)
>
> When I compile/deploy/run in netbeans - my web application falls over,
> in firefox I get a very brief error (HTTP 404 - the requested resource
> () is not available), I get nothing in the netbeans glassfish console.
>
> I have placed some System.out.println to help me debug the sequence of
> events, and I can see that DBHandler.java is never called
>
> Can some one please point out what exactly should the syntax be for
> forwarding from JSP->servlet (i.e. the JSP forward syntax), should
> there be '/' or not?? does web.xml take care of the mapping from name -
> location??


Is /DBHandler mapped to the servlet?

On the other hand I strongly recommend that you do it the other way
around:
- form is posted to servlet
- servlet does validation and transaction
- servlet forward to JSP

Arne


Arne Vajhøj
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
2007/April/02 new programs, and Physician Database for USA 2007 EDITION, and the 19 Millions Vol.14 EMail Address List CD kashumoto_tokugawa Computer Information 0 04-02-2007 05:55 PM
Unable to compact/repair database John Computer Information 8 07-10-2006 11:56 AM
Updates *****General Computer Support 6 09-18-2004 12:13 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46