- Posted by: e d
- Posted on: April 23 2001 04:28 EDT
i have some problems and even with many documentation i don't know why it doesn't works or didn't find the correct answer.
my problem is quite simple i think :
how to call a servlet from a jsp ?
i do have a web app (called MyWebApp) and i have defined a servlet called MyCookie.
what i want is to call this servlet form a post method in a form.
I'm using IBM Websphere and in the red book they write this :
<FORM METHOD="POST|GET" ACTION="application_URI/JSP_URL">
i made this :
<form name = "myForm" ACTION="/MyWebApp/MyCookie" METHOD="POST">
i tried this too :
<form name = "myForm" ACTION="MyCookie" METHOD="POST">
but the result is : error 404, the page cannot be found.
what is the real path to put in the field ACTION to call a servlet ?
well in fact i have found a begun of solution but not the entire one.
it seems that the way to call a servlet is :
(in a <FORM ACTION="..." METHOD="POST"> or by entering the path in the navigator) (as it is written in IBM red books Servlet and JSP programming)
if i put something else the navigator answer "page not found" and if i use the path "/servlet/name_of_the_class" (in my case "/servlet/ShowParameters" ) , the server answer something like :
" ERROR 500
An error has occured while processing
Message:Server caught unhandled exception from servlet[invoker]
Target Servlet: invoker
Root Error-1: ShowParameters
java.lang.ClassNotFoundException: ShowParameters at .....
Wrapped Error-2: Servlet [ShowParameters]: Could not find required servlet class -
javax.servlet.ServletException: Servlet [ShowParameters]: Could not find
required servlet class - ShowParameters.class at ...."
and if i call an other servlet - that is on the same directory than the
one i tested above - in the browser with the same way
("/websphere/servlet/servlet_that_works")it works !!
Both servlet (the one that works and the one that not) are in the same directory, are both .class and are both called with the same method. but only one of them function.
this thing is getting me mad.
if you have any idea please tell me, i gonna search by my own too as always even if I'm really lost
I have only used WebSphere a couple of times however if I remember right WS is very picky about servlets being register through the admin tool. In the admin tool make sure to select the correct servlet container (you could be running multiple JVM's) and register the servlet with this container. At that point I "think" you should be able to call your servlet directly without having to use the /servlet/.
hope this helps.
Check the <servlet> and <servlet-mapping> tags in your web.xml.
You should have something like:
Then access it thru: /MyWebApp/MyCookie