• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

runtime ERROR

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thiss is my servlet


this is my BasicCounter.jsp


i put servlet class file in D:\Tomcat\apache-tomcat-6.0.18\webapps\test\WEB-INF\classes\foo
and i put jsp file D:\Tomcat\apache-tomcat-6.0.18\webapps\test\WEB-INF

this is my web.xml


but when i type this in broser http://localhost:8080/test/BasicCounter.jsp it gives this eror

 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anarkali.

Anything that is put under WEB-INF folder, will not serve directly to the client.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now jsp file is in
i put jsp file D:\Tomcat\apache-tomcat-6.0.18\webapps\test
but error is there still.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you pasted the correct codes for servlet and jsp, the codes you have pasted appear to be plain java class.
 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anarkali.

Here foo.Counter is not a servlet. I think this causes the application fail during deployment. Ultimately any request's to it will not be served.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again I am not finding anything related to any servlet, as per the code what is happening is a java class is being accessed from jsp. You are using a jsp file, and if that is not under web-inf you don't need any mapping for that, i.e. what you are doing right now accessing it directly from url.

Can you show your complete folder structure once again.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is my BasicCounter.jsp



this is my Counter.java servlet


this is my web.xml


this is the where servlet put D:\Tomcat\apache-tomcat-6.0.18\webapps\test\WEB-INF\classes\foo
this the where jsp put D:\Tomcat\apache-tomcat-6.0.18\webapps\test

this is what i type in browser http://localhost:8080/test/BasicCounter.jsp/
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Few things are confusing here.

1. Jsp calling a method from a servlet, I guess this could have been a plain java class.
2. There is file called BasicCounter.jsp and in web.xml there is a url-mapping as BasicCounter.jsp mapped to the servlet, so on request which one should be invoked?
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why is it error?
anyway if it is a plain java class what should be in web.xml
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

this is what i type in browser http://localhost:8080/test/BasicCounter.jsp/


But that isn't what your servlet is mapped to.

It's really unclear what you're trying to do. Are you trying to access a JSP, or a servlet? Is there a reason you're trying to write this the way you are rather than using current servlet practices?
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://localhost:8080/test/BasicCounter.jsp/

probably the last / is creating the problem, it should have been

http://localhost:8080/test/BasicCounter.jsp

At least it wont show the 404 error. But still you are unlikely to get the desired output. Because as per web.xml mapping servlet will be executed and which is not producing any output. To invoke the jsp file you need to remove the servlet and servlet-mapping sections from your web.xml file.


 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually this is a example of HeadFirst servlet & Jsp book.page number is 288.

in this example there is no servlet.there is a plain java class.but web.xml file is not there.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So why do you have a web.xml file?
reply
    Bookmark Topic Watch Topic
  • New Topic