wood burning stoves 2.0*
The moose likes Servlets and the fly likes Running servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Running servlets" Watch "Running servlets" New topic
Author

Running servlets

vidhya subramaniam
Ranch Hand

Joined: Jul 14, 2001
Posts: 91
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
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
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

Joined: Sep 19, 2001
Posts: 273
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

Jayanthimeena
Greenhorn

Joined: Jul 24, 2001
Posts: 17
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

Joined: Sep 19, 2001
Posts: 273
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

Joined: Jul 14, 2001
Posts: 91
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

Joined: Jul 14, 2001
Posts: 91
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
 
 
subject: Running servlets