aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes How to invoke a servlet using URL - http://localhost:8080/servlet/ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "How to invoke a servlet using URL - http://localhost:8080/servlet/" Watch "How to invoke a servlet using URL - http://localhost:8080/servlet/" New topic
Author

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

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

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

Joined: Sep 23, 2010
Posts: 422
Include ROOT in URL.

http://localhost:8080/ROOT/servlet/


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

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

Joined: Jul 13, 2010
Posts: 610

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?


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

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

Joined: Jan 10, 2002
Posts: 60975
    
  65

Bad idea.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Bad idea - in real world.
Good idea - to learn.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Bad idea to use it, good idea to avoid it ;-)
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

By saying "Hope it'll be useful to you as well" I meant the article, not InvokerServlet.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

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

Joined: Aug 31, 2006
Posts: 355

@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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to invoke a servlet using URL - http://localhost:8080/servlet/