Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing Servlet File using Tomcat

 
Mahera Shaikh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m completely new the Servlet, I m unable to run the servlet file using the URL
http://localhost:8080...
I instld Tomcat 7.0, Made a source class file..
but dnt know how to execute file..
Please ne one can provide me step by step procedure to run the Servlet file..
Please....
 
Rajani Gummadi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below are the steps you need to follow.

1) Write the servlet class.
2) Configure web.xml or through some annotations based on the version you are using.
3) build war file.
4) deploy the war file
5) invoke the servlet like http://localhost:8080/<<app/contextname>>/<<URL pattern>>

If you had looked into FAQS session, you would certainly find examples on how to setup the web application or through google

All the best.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Click here

Welcome to Javaranch Mahera i also dont know much about servlets but did a little google search
 
Mahera Shaikh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx Rajni G Sir..
But i need it in quiet clarified language...
Each step with exaplanation....


Please do post with detailed explanation...
 
Rajani Gummadi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahera Shaikh wrote:Thnx Rajni G Sir..
But i need it in quiet clarified language...
Each step with exaplanation....


Please do post with detailed explanation...


Hi Mahera, have you considered looking at the example which Vishal provided or the "HelloWorld" servlet given in the link provided? What are the issues you are facing in understanding those examples? Please do not hesitate to ask your questions, but I would still ask you to look into those links before.
 
Mahera Shaikh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realy dint get so asking...
Please do help me...
Wil b vry greatful...

 
Mahera Shaikh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx vishal...
I tried with Rose India..
but getng a error report
File Not found...
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mahera,

Its ok if you call us by our names..You dont wanna mistakes by calling some lady Sir(unless you are pretty much sure about it)

File not found Exception.....hmmmm

Might be ....

File doesnot exists
Path must be wrong
Class path defined wrong
(well just my rough guesses)
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahera Shaikh wrote:I tried with Rose India..

Don't ever use that site - it's full of erroneous code, bad advice and bad practices.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
Mahera Shaikh wrote:I tried with Rose India..

Don't ever use that site - it's full of erroneous code, bad advice and bad practices.


what about its theory knowledge for basics??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:
Ulf Dittmer wrote:
Mahera Shaikh wrote:I tried with Rose India..

Don't ever use that site - it's full of erroneous code, bad advice and bad practices.


what about its theory knowledge for basics??

I agree with Ulf. It is not a good site. Teaching bad code and poor practices is not a good way to learn basics or anything else.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Bear Bibeault ,Ulf Dittmer for letting me know
 
Mahera Shaikh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf....
Please if you can provide me with a link thn i wil be vry greatful...
Many tricks many practises thn to cnt execute the servlet file...
Actuly dnt kno wher to store the class file nd how to cal it on the browser page...
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Under you application root(context) directory, you should have a folder called WEB-INF, which should have another folder called classes. You should keep your class file under the classes folder. In addition to this you should have another file web.xml(deployment descriptor) which specifies the url mapping details for the servlet. This file should kept in WEB-INF folder.

For e.g. you have a servlet called MyServlet. The you should keep the MyServlet.class under WEB-INF\classes. Now you have to create your web.xml something like this


Save this as web.xml in WEB-INF folder. I assume your context folder name is mysite

Restart tomcat and try to execute like
http://localhost:8080/mysite/test
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahera Shaikh wrote:... thn i wil be vry greatful...
Many tricks many practises thn to cnt execute the servlet file...
Actuly dnt kno wher to store the class file nd how to cal it

Again, please UseRealWords when posting...
 
Mahera Shaikh
Greenhorn
Posts: 6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much swastik...
I got the problem solved.....

Regards,
Mahera
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to be of some help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic