• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Invoking servlets in tomcat

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to know
1. can i compile the servlets using servlet.jar of tomcat or j2ee.jar of j2sdkee1.3.1
2. after compiling that how to set the path in autoexec.bat and how to set the environment variable(Do i need to set both of them or not)

3. where to place my servlet source code, class file and what is url i need to type in the browser.
4. how to see the results(servlet) on command prompt

Help will be appreciated
thanks in advance
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sunny T:
I would like to know
1. can i compile the servlets using servlet.jar of tomcat or j2ee.jar of j2sdkee1.3.1
2. after compiling that how to set the path in autoexec.bat and how to set the environment variable(Do i need to set both of them or not)

3. where to place my servlet source code, class file and what is url i need to type in the browser.
4. how to see the results(servlet) on command prompt

Help will be appreciated
thanks in advance



1. Yes add servlet.jar to your class path
2. you should only need to set environment variables if you are using a relatively recent microsoft windows. to do this go into control panel - > system - > advanced - > environment variables
3. place the source code where you wish, the compiled class files go in tomcat/webapps/somecontext/WEB-INF/classes
the url you type is http://localhost:8080/somecontext/servlet/MyServletName
4. i don't know what you mean, but if you want to see the code generated by the servlet you use a browser. you cant tell much from the command prompt
seems like you need to read some tomcat tutorial / manual.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim..
I have tried the one given by u, but still it is not displaying the result.
HTTP 404 error
i have placed my class file in C:\Tomcat 4.1\webapps\examples\WEB-INF\classes
and in the url i have typed http:\\localhost:80\examples\servlet\Helloworld
1. My server is running in port 80, and Helloworld is my servlet name
2. I have compiled my servlet using j2ee.jar of j2sdkee
3. if i want to print some message using System.out.println is it possible with sevlets

Thanks in advance
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You need to enable the INVOKER servlet in Tomcat. Although this was enabled by default in earlier version of Tomcat, in later versions it is the opposite.
So, edit the WEB.XML file in the CONF directory and un-comment the "<servlet>" and "<servlet-mapping>" entries for the INVOKER servlet.
Restart Tomcat and everything will be fine.
BTW, the INVOKER servlet has some security issues so you are better off using a <servlet-mapping> to get to your servlets. This is cool for development though.
Regards
Darren.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sunny T:
Hi Sunny..
[QB]I would like to know
1. can i compile the servlets using servlet.jar of tomcat or j2ee.jar of j2sdkee1.3.1
sol : Yeah u need servlet.jar
2. after compiling that how to set the path in autoexec.bat and how to set the environment variable(Do i need to set both of them or not)
sol: u can set path in one of the 2 ways...
Either by setting values in Environment variable Tab or by editing autoexec.bat file
3. where to place my servlet source code, class file and what is url i need to type in the browser.
sol: Suppose u have your 'Hello.java' servlet file in 'Trialweb' folder then u place the above folder as shown below
C:\jakarta-tomcat-3.3.1a\webapps\Trialweb
and after u can copmile the servlet by using javac -d command or by javac and copy the class file from the current location to
C:\jakarta-tomcat-3.3.1a\webapps\Trialweb\WEB-INF\classes
4. how to see the results(servlet) on command prompt
After doing the above task u can start the tomcat.
And when the enginee is started u can go the browser and type the below
http://localhost:8080/Trialweb/servlet/Hello

I hope u will find the output (result ) of servlet... but in browser...

Hey! what exactly u want in command prompt..?

Preeti

 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sonny T, welcome to JavaRanch.
Just a little detail. Your user name doesn't quite fit the famous JavaRanch Naming Policy - got to show 2 names (the second name needs to be more than a single letter).
Please take a minute to change your display name to show two names, preferably real names. It's all about maintaining our professional image - don't let's the one-eyed moose fool you!
Hope you'll be visiting the ranch often,
Pauline
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic