• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

I am not able to run JSP and Servlets :(  RSS feed

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody :
I am quite new to jsp and servlets . I am usin JDK1.3 ,and I got two problems.
1)I downloaded Tomcat 3.1 .
when i went to their website i was confused which file to download and somehow i downloaded Tomcat.bat file.
when i set up and when was trying to run the tomcat
i did set
Set TOMCAT_HOME="C:\jakarta-tomact\tomcat"
Set JAVA_HOME ="C:\JDK1.3"
in my Autoexec file
when i tired to run my program
c:\jakarta-tomact\tomcat\bin\startup
a window opens and closes .
Do i have to do anything else.
2)Does JDK1.3 have servlet API or do i have to download it ?
if it does have how can i compile my servlets?
Thank you
I know i am vague i am sorry abt it
i am quite new To JSP and servlets
rgds
siva
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I donot know what u have down loaded. For correct down load
you paste the following URL in a download manager like flashjet, gorilla or simply paste on your browser window you will start down loading TOMCAT 3.2 latest beta version(I am using it).
http://jakarta.apache.org/builds/tomcat/release/v3.2-beta-7/bin/jakarta-tomcat-3.2-b7.zip
Unzip the above file in c:\ or d:\ and you can rename the dir jakarta-tomcat to "tomcat" for easy use.
Follow the information given by Prasad in the same page
visit this site for tutorials http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
solaiappan

 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Solaiappan:
Now my Tomcat is workin good after i followed the instructions of prasad.
I do not know how to compile my servlets and where shoudl store in the tomcat server to run my servlets?
Thank you
Siva
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
why don't you go throgh the nice documentation give by TOMCAT people and the examples given by them??
It is in \jakarta-tomcat\doc\ directory.
Don't forget to include "servlet.jar" file in your classpath for e.g
set classpath=%classpath%;c:\java1.3\lib\tools.jar;D:\jakarta-tomcat\lib\servlet.jar
then compile your servlet program
you can keep your servlet/jsp file in "\jakarta-tomcat\webapps\ROOT\WEB-INF\classes\" dir
for e.g if your servlet name is "MyFirstServlet" then run like this http://localhost:8080/servlet/MyFirstServlet
solaiappan

[This message has been edited by P SOLAIAPPAN (edited November 15, 2000).]
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Solaiappan:
I have a FirstServlet and firstServlet.html file
I placed in my C:tomcat directory
but when i call http://localhost:8080/firstservlet.html
It does not work
Am i doin any mistake?
rgds
Siva

 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Sorry for the mistake, I have edited my above message
solaiappan
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear SOLAIAPPAN:
Thank you .
Now I am able to run my servlets .
But i was not able to compile these program
ServletUtil.java
package test ;
public class ServletUtil {
public static final String DOCTYPE = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
public static String headWithTitle(String title){
return (DOCTYPE + "\n" +
"<HTML>\n" +
"<HEAD><TITLE>" + title + "</TITLE></HEAD>");
}

};
Hello.java
package test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Hello extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException , IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println(ServletUtil.headWithTitle(" Hello WWW ") + "\n" +
"<BODY>\n" +
"<H1> Hello WWW -- BY Siva </H1>\n" +
"</BODY></HTML>");
}
};
These two file are present in the c:\tomcat\source\test
I am generating the class files in
c:\tomcat\webapps...\classes\test
when i compiled ServletUtil it did well , but when i compiled Hello.java the compiler was sayin that it can't undestand
ServletUtil.headWithTitle(" Hello wwww");
can u pls help me in this
Thank you
rgds
Siva
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Siva,
Your program is compiling & running without any problem in my computer.
C:\tomcat\webapps\ROOT\WEB-INF\classes\test

(a) First you compile ServletUtil.java in "test" dir as your package is test
(b) Then compile Hello.java as above

Run as "http://localhost:8080/test/servlet/Hello"
or
as "http://localhost:8080/servlet/test.Hello"
It prints "Hello WWW -- BY Siva "
I thing your compilation error is due to classpath problem. The compiler is not able to locate your ServletUtil.class file.
in dos prompt type "set classpath=%classpath%;c:\tomcat\webapps\ROOT\WEB-INFO\classes"
then compile your Hello.java, NO ERROR!!

solaiappan


[This message has been edited by P SOLAIAPPAN (edited November 16, 2000).]
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear SOLAIAPPAN:
I really appreactiate you.
Thanx for helping me .
When i compile my ServletUtil.java
it compiles and get this message
[wrote c:\Tomcat\webapps\ROOT\WEB-INF\classes\test\ServletUtil.class
But when i compile Hello.java
i get this message
test/Hello.java:15: cannot resolve symbol
symbol : variable ServletUtil
location: class test.Hello
out.println(ServletUtil.headWithTitle(" Hello WWW ") + "\n" +
I guess i am plavin the files in the Wrong place
i have placed both the files in the
c:\>tomcat\source\test directory
I am generating the classes in
c:\>tomcat\webapps\root\..\classes\test
infact i can ServletUtil.class file is present in the above directory
i am compilin these programs using a BAT file
@echo off
rem To run servlets
SET CLASSPATH = %CLASSPATH% ;c:\Tomcat\webapps\ROOT\WEB-INF\classes\test;
SET CLASSPATH = %CLASSPATH% ; c:\tomcat\source;c:\tomcat\source\test;
javac -verbose -d c:\Tomcat\webapps\ROOT\WEB-INF\classes %1%
this file is present in c:\>tomcat\source
I am struck here
rgds
siva
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have understood your problem. See my EDITED message
solaiappan
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear SOLAIAPPAN:
Thanx A Lot !!!
Atlast it worked
thank you
rgds
Siva
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!