tags:

views:

37

answers:

1

JSP CODE:

Upload File:
<input name="file" type="file" id="file"><br><br>
<input type="submit" name="Submit" value="Submit"/><br><br>
<input type="reset" name="Reset" value="Reset"/>   
</form>

I have the above JSP file which will be executed with the help of Tomcat server and this is stored in the following location of my system.

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\CheckURL

I have written a servlet program for catching the request and sending the reponse from the given JSP file.

My query here is, in which path the servlet program must be stored in my system.

And please let me know whether a servlet program can be compiled using javac NewServlet.java or it can be executed directly during runtime. Because on compiling that servelet program I get a lot of errors.

Am a beginner in java. If u can give me a detailed outlook on the above issue, it would be of great use. Thanks in advance.

+3  A: 

The servlet tutorial is a good place to start.

A few points to answer your particular questions:

  • you can compile a servlet with javac NewServlet.java but you have to specify classpath (-cp) that contains the servlet-api.jar
  • you store the .class file in webapps\checkURL\WEB-INF\classes
  • you map the servlet in WEB-INF\web.xml using <servlet> and <servlet-mapping>. (there is a easier way with Tomcat 7 and Servlets 3, but you are on 5.5)
Bozho
Is servlet-api.jar file a compulsory one for compiling? If so, where to download the jar file?
LGAP
You don't download it separately. It's part of the servletcontainer. You already have one (Tomcat). Just add path to `Tomcat/lib/servlet-api.jar` to compiletime classpath. Your *actual* problem is not related to Servlets, but to basic Java. I'd suggest to learn about basic Java/Javac/Classpath first before diving into Servlets :)
BalusC
@BalusC what must be given in the <form action="?"> of the JSP code?
LGAP
the URL to which you have mapped the servlet (with `servlet-mapping`)
Bozho