• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Running servlets

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to servlets and i would like to know how to run them. I went through the jdk specs and downloaded tomcat as well as jsdk to try running either was but didnt succeed. According to the documentatuion i tried giving command startserver in dos prompt after goin to jsdk dir but it doesnt recognize it. i am not able to run it from tomcat either. i am working on windowsNT. can somebody please explain.
vidhya
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Remove all traces of the old JSDK from your system - that is completely out of date and NOT supported by Sun. I have no idea why people keep downloading jsdk when the Sun site clearly says that Tomcat is the current version.
2. Tomcat has everything you need. You should be able to install Tomcat, open a MSDOS prompt window, change to the tomcat\bin directory and run the startup.bat file and get a working server at port 8080.
3. With a browser go to http://localhost:8080/
and you should get the Tomcat start page.
4. If it doesn't work, make note of the error messages.
Bill
 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill:
I have been working since last three days. How to compile servlet? It is not comming out. Please help.
Tomcat is running. I can execute tomcat servlet examples. They work fine. But I can not compile my simple servlet as below.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HTTPServlet
{
public void doGet(HTTPServletRequest req,
HTTPServletResponse res)
throws HTTPServtException, IOException
{
PrintWriter out = res.getWriter();
out.println("Hello");
}
}
I had following errors.
HelloServlet.java:2 package javax.servlet does not exit
HelloServlet.java:2 package javax.servlet.hhtp does not exit
I have set class path C:\tomcat\lib\servlet.jar. Set TOMCAT_HOME = tomcat. SET JAVA_HOME=jdk1.3. Even I copied servlet.jar file from tomcat/lib folder to tomcat\webapps\example folder. This is the place where I am compiling my servlet. It did not help. It is really frustating. BK

Originally posted by William Brogden:
3. With a browser go to http://localhost:8080/
and you should get the Tomcat start page.
4. If it doesn't work, make note of the error messages.
Bill[/B]


 
Bal Sharma
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vidha
I can tell you half the story how to run tomcat. It is working for me. Let me tell you how did I get it. If you follow as I did I believe you will get it.
Download tomcat
Unzip tomcat, you will get tomcat-jakarta long name folder.
I saved it in just tomcat.
My machine is windowME. Chaneged path C:\tomacat\lib\servlet.jar
set TOMCAT_HOME = tomcat
set JAVA_HOME = C:\JDK1.3
OPEN DOS COMMAND.
CD TOMCAT
CD BIN
STARTUP
You will see message tomcat satrted. Open browser, type http:\\127.0.01:8080\examples\servlet\HelloWorldExample HIT ENTER YOU WILL SEE SERVLET RUNNING LOCALLY.
THAT IS IT. BK

Originally posted by vidhya subramaniam:
Hi,
I am new to servlets and i would like to know how to run them. I went through the jdk specs and downloaded tomcat as well as jsdk to try running either was but didnt succeed. According to the documentatuion i tried giving command startserver in dos prompt after goin to jsdk dir but it doesnt recognize it. i am not able to run it from tomcat either. i am working on windowsNT. can somebody please explain.
vidhya


 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai
All u done is correct only.
Try this this will work.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
PrintWriter out = res.getWriter();
out.println("Hello");
}
}
Bye
Jayanthi
 
Bal Sharma
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jayanthi:
I tried your solution same problem. Could any one please let me know how to fix this problem. Why "package HttpServlet and HttpServlet.Http" are not recognized. Do I have add these package separately? Then what is use of servlet.jar file? I do not know please help.

Originally posted by Jayanthimeena:
Hai
All u done is correct only.
Try this this will work.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
PrintWriter out = res.getWriter();
out.println("Hello");
}
}
Bye
Jayanthi


 
vidhya subramaniam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i tried the same way as Bill has explained but when i type in the host name in the browser it gives me the foll error:
Bad Gateway
The following error occurred:
A DNS lookup error occurred. The host was not found.
Please contact the administrator.
why is this error? how can i proceed now.
i am using NT and i set the path also to servlet.jar.
 
vidhya subramaniam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i have done all the step by step procedures as explained by Bill. I have also set the path as servlets.jar. i am using windowsNT.
but when i try to type in the browser after startiing tomcat it gives me the folowing error:
Bad Gateway
The following error occurred:
A DNS lookup error occurred. The host was not found.

Please contact the administrator.

how must i proceed now. can someone pl explain
vidhya
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic