Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Status 404

 
Deepan Ignatius
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have placed my compiled servlet code identical to this location "c:
\...\LApps\WEB-INF\classes\coreservlets\ShowBalalnce"
which in turn is
using another servlet class BankCustomer present in the same location.


While trying to access the servlet ShowBalance using this URL:
http://localhost:8181/LApps/coreservlets.ShowBalance?id=id001, I am
getting 404 error page stating that "/LApps/coreservlets.ShowBalance
is not available. "



PS: Inside the ShowBalance servlet, if the id is id001 then I am
forwarding the request to a JSP. So my expectation is that it should result in a jsp page
but it isnt.

Can anyone of you correct me?

Thanks in advance!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you add servlet mapping information to your WEB-INF/web.xml file? Classes are not made available automatically as this would be a security issue.
 
Roshan Ramesh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ensure that you have proper mapping information for "coreservlets.ShowBalance" in WEB-INF/web.xml.

Without this, you tend to get that 4xx class of errors.
 
Deepan Ignatius
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,

I dont have web.xml. I did this intentionally as I am not sure of how to pass a parameter using it.

How to add a web.xml entry for this?

ex:-

<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>coreservlets.ShowBalance</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>

Hwow to include a parameter[?id=id001] in this?
 
Deepan Ignatius
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it.

Thanks for your inputs.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's good to follow up with the answer to your question so that other people with the same problem can learn! Thanks!
 
Deepan Ignatius
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Using url like this "/hello?id=id001" has solved the problem.

Thanks.
 
Deepan Ignatius
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Snippet of my web.xml

<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>coreservlets.ShowBalance</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>

J2EE level - J2EE 5
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic