tags:

views:

145

answers:

2

How can I run a jsp program?

+2  A: 

The first result of a google search.

Under the Tomcat root directory there will be a sub-directory named web-apps, all web applications running on this Tomcat server will reside there. Each web application will have it's own sub-directory under web-apps, so you could create a directory for your web application under the web-apps directory like so /web-apps/. JSP pages can be placed insisde the directory you have created or in other sub-directories you might like to create, however please note that for each new sub-directory you place your JSP files in the URL to access them will need to include each directory.

Inside the directory you created there needs to be another directory named WEB-INF, this directory will contain the web.xml file which contains configuration information for your web application such as the welcome file for your application, all servlet mappings, filters, etc...

Under the WEB-INF directory you can create another directory named classes, all your java classes used in your web application should be placed in here, in a tree structure that resembles their packages, for example: if you have a class named MyClass whose package is com.xyz then the class should be placed in /web-apps//WEB-INF/classes/com/xyz/MyClass.class. Another alternative to handling classes in this way is to package them all in a jar file, the jar file can be placed in a directory named lib also under the WEB-INF directory, for example: say you have a jar file named myLibrary.jar, it can be placed in /web-apps//WEB-INF/lib/myLibrary.jar. By placing classes and jar files in these directories Tomcat ensures they are on the CLASSPATH when you run your application.

An alternative to repeating this procedure each time you want to deploy some JSP pages to your Tomcat server is to simply create a WAR file and use the Tomcat manager (which can be accessed through a browser window) to deploy the WAR file to the server.

Source

rahul
+4  A: 

You need to have a JSP capable web-server or application server. Check Apache Tomcat project. And follow the documentation that phoenix provided.

Check this link. It gives more info

http://www.jsptut.com/Getfamiliar.jsp

Umesh