![]() |
|
|
|||||||
![]() |
Java - cannot get my JSP to forward to database-handler servlet (innetbeans) |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |