• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to invoke a servlet using URL - http://localhost:8080/servlet/

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a very simple servlet and placed it in folder: tomcat\webapps\ROOT\WEB-INF\classes\
I read there is no need to mention such servlet in web.xml. So, I didn't.
Still, I am unable to invoke my simple servlet What am I missing? Please guide me.

Port etc. are correct. I am able to invoke other servlets.
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Include ROOT in URL.

http://localhost:8080/ROOT/servlet/
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ROOT is never specified! Everything under ROOT will be invoked as, for e.g. http://localhost:8080/ and NOT as http://localhost:8080/ROOT/
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a simple servlet?
What Tomcat version?
What Servlets version?
Where did you read that you don't need to mention it in web.xml? Did you use annotations?
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must enable InvokerServlet. I am still reading the stuff present here: http://www.coderanch.com/how-to/java/InvokerServlet

Hope, it'll be useful to you as well.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad idea.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad idea - in real world.
Good idea - to learn.
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad idea to use it, good idea to avoid it ;-)
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By saying "Hope it'll be useful to you as well" I meant the article, not InvokerServlet.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal Ahmad wrote:Good idea - to learn.

Nope. That's like saying smoking is a good idea "to learn". Bad habit. Don't even start.

You learn nothing by using the Invoker -- you simply get used to doing things in a way that has been demonstrated to be a bad practice. And in doing so, avoid learning how to map servlets the correct way.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear,@Pedro - I completely agree with you.

By saying, "Good idea - to learn", I meant:
- learnt that there exists (tomcat v5.5.31.0) something called InvokerServlet
- learnt that there exists a way to invoke servlets through such URL
- learnt how bad such practice is (the curiosity made me read the article here and explore more about InvokerServlet at few other places as well)

I noticed, my replies were abstract! Many thanks for your replies!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic