Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in run the servlet in tomcat 5.5

 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello joseph here

In the classes folder i have servlet called lifecycle, which i compiled and have lifecycle.class file.

how to run. i request the url as

[URL=http://localhost:8080/website/lifecycle[/url]

it gives 404 error.
 
Shahnawaz Shakil
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to run the servlet directly by typing url in the address bar then the servlet should support doGet method. Secondly the url should be in accordance with the url-pattern tag of servlet mapping in web.xml
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you mapped the servlet in your web.xml file as, If not then look at this !
 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where i can find the web.xml . did i have to write explicity in the WEB-INF directory.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you have to ! Its in WEB-INF/web.xml
 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
without the web.xml the jsp program are running.

did i have to write the web.xml. for this . is there any way to create the web.xml automatically.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, when we request the .jsp pages, its get compiled and retrued by servlet container to browser.

But the servlets are mapped by the URL pattern to actual stored Servlet class

e.g



Here is the basic web.xml file from tomcat
 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is any command to create the web.xml automatically as like in weblogic server
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, as far as my knowledge is concerned there is no command to build web.xml from tomcat server, but you can use build tools like Ant and there are IDE like Netbeans which add the entry of each new Servlet class you creates !

But I suggest you crate or write the web.xml elements yourself, that makes your basic clears and helps in understanding the things !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic