aspose file tools*
The moose likes Servlets and the fly likes Help in compiling Servlet program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help in compiling Servlet program " Watch "Help in compiling Servlet program " New topic
Author

Help in compiling Servlet program

Siva Jagadeesan
Ranch Hand

Joined: Oct 31, 2000
Posts: 160
Hi everybody
I am using tomcat3.1 in windows98 machine
it works fine
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


Rgds<p>--Siva Jagadeesan<br /><a href="http://java2simple.blog-city.com" target="_blank" rel="nofollow">http://java2simple.blog-city.com</a><br />Sun Certified Java2 Programmer<br />Sun Certified Web Component Developer<br />BEA Certified Weblogic Server 7 Enterprise Developer
Paul Wetzel
Ranch Hand

Joined: Nov 02, 1999
Posts: 107
I see a couple of typos and I dont know if that is the problem but the Hello class has a ; after the last }
could that be it?
paul
Preethi Chaloori
Greenhorn

Joined: Oct 04, 2000
Posts: 13


Hi! SivaKumar,
I do not believe that the compiler will complain about the ";" at the end.
It generally shouldn't matter but you could try doing this:

String title = ServletUtil.headWithTitle(" Hello WWW ");
out.println(title+........whatever your code );
Preethi

Originally posted by Sivakumar Jagadeesan:
Hi everybody
I am using tomcat3.1 in windows98 machine
it works fine
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

Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
I using jdk1.3 & tomcat 3.1.
I can start and stop the tomcat server using port 127.0.0.1
I can compile and runing the follong simple program with the enclosed setting. Hope this helps...
Do you have the follow env var...
PATH=c:\jdk1.3\bin;c:\tomcat\bin
JAVA_HOME=c:\jdk1.3
TOMCAT_HOME=c:\tomcat
CLASSPATH=,;c:\tomcat\lib\servlet.jar
...................
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Very simplistic servlet that generates plain text.
* <P>
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* � 2000 Marty Hall; may be freely used or adapted.
*/
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}

[This message has been edited by Monty Ireland (edited November 16, 2000).]


Multi Platform Database Developer & DBA on E.S.T.
Siva Jagadeesan
Ranch Hand

Joined: Oct 31, 2000
Posts: 160
Hi everybody :
I finally made my programs work . I made some mistake in setting up my classpath
Thank you Preethi Chaloori and Monty Ireland
rgds
Siva
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help in compiling Servlet program