Tuesday, July 14, 2009

How to compile java file in Tomcat ?

Hi all,


I have a java file named Ch1Servlet.java under project1/src directory


there is classes directory project1/classes and web.xml under src directory


project1/src directory.


Now to compile i have to give %javac -classpath /your path/tomcat/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java


What is this your path ? Tomcat 5.0 is installed in C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib with servlet-api.jar


Please help me out.


Best Regards


Taton








import javax.servlet.*;


import javax.servlet.http.*;


import java.io.*;


public class Ch1Servlet extends HttpServlet {


public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {


PrintWriter out = response.getWriter();


java.util.Date today = new java.util.Date();


out.println("%26lt;html%26gt;"+"%26lt;body%26gt;"+"%26lt;h1 align = center%26gt;HF\'s Chapter 1 Servlet%26lt;/h1%26gt;"+"%26lt;br%26gt;"+today+"%26lt;/body%26gt;"+"%26lt;/...


}


}

How to compile java file in Tomcat ?
K ban try this link and learn





http://www.coreservlets.com/Apache-Tomca...
Reply:place u r virtual directory in webapps folder


put ur classes file as below


web-apps


virtual directory(projects)


WEB-INF


web.xml,Classes(Folder)


ur java compiled .class files


No comments:

Post a Comment