Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Hand
Posts: 355
Redhat Chrome Java
  • 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.
 
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
Redhat Chrome Java
  • 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/
 
Ranch Hand
Posts: 623
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
Redhat Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must enable InvokerServlet. I am still reading the stuff present here: https://coderanch.com/how-to/java/InvokerServlet

Hope, it'll be useful to you as well.
 
Sheriff
Posts: 67405
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad idea.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Redhat Chrome Java
  • 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: 623
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
Redhat Chrome Java
  • 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
Sheriff
Posts: 67405
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Redhat Chrome Java
  • 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!
 
no wonder he is so sad, he hasn't seen this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic