This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes JSP problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP problem" Watch "JSP problem" New topic
Author

JSP problem

bujji goud
Greenhorn

Joined: Sep 21, 2007
Posts: 12
sir I created a servlet and at the end forwarding to some JSP using request dispatcher object...
Every time iam getting HTTP status 404 error why...iam using tomcat...please tell me where iam going wrong...
[ September 21, 2007: Message edited by: Bear Bibeault ]
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Hi,

Please post your code.

Where are you getting the RequestDispatcher reference from ? Are you getting it from the request object or from the ServletContext ? Are you using a relative or an absolute path ?

Please take the above assumptions into consideration and please post your source code.

Best of luck ...


Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
bujji goud
Greenhorn

Joined: Sep 21, 2007
Posts: 12
iam getting dispatcher from request object....
Here iam mainly suffering from HTTP status 404 in tomcat server....
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Why don't you post your code!
bujji goud
Greenhorn

Joined: Sep 21, 2007
Posts: 12

soluion please......
[ September 21, 2007: Message edited by: bujji goud ]
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Where does your JSP file reside inside TomCat ?
bujji goud
Greenhorn

Joined: Sep 21, 2007
Posts: 12
just inside of my web-application:
path:C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Accounting Application\jspfile
Originally posted by Vassili Vladimir:
Where does your JSP file reside inside TomCat ?
Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
And what does your servlet map to? Because the RequestDispatcher from the HttpServletRequest object accepts a relative URL and you've passed it 'texttotable.jsp' which would make it relative to the current request.
bujji goud
Greenhorn

Joined: Sep 21, 2007
Posts: 12
Originally posted by Tarun Yadav:
And what does your servlet map to? Because the RequestDispatcher from the HttpServletRequest object accepts a relative URL and you've passed it 'texttotable.jsp' which would make it relative to the current request.

this is my web.xml
Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
Originally posted by bujji goud:

this is my web.xml


And you'd said your JSP is in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Accounting Application\jspfile\.

So that means the container is trying to forward to http://localhost/AccountingApplication/binttotext/texttotable.jsp whereas your JSP is at http://localhost/AccountingApplication/jspfile/texttotable.jsp

So modify your path accordingly. Make it "/jspfile/texttotable.jsp" instead.

Also, while we're at it, why is your application name "Accounting Application"? I'd suggest not using a space in your context name.
bujji goud
Greenhorn

Joined: Sep 21, 2007
Posts: 12

jspfile:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\AccountingApplication\texttotable.jsp

servlet path:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\AccountingApplication\WEB-INF\classes\bintotext1.class
now tell me what i should do now iam not gettong with the above words...

Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
Ok...first, try to access each resource individually.

Comment out the forward in the servlet and try to access it by typing in the path. Next, try to access the JSP.

Then, check your logs ( $CATALINA_HOME/logs ) for any clue to exceptions being thrown. And instead of simply printing the exception message, use printStackTrace() to get more information.

Also, I'd suggest you put all your classes in a package, it's not recommended to put them in the default package. This includes your servlets.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSP problem