How to run a servlet program?
Answers were Sorted based on User's Feedback
Answer / subrahmanyam
We have to Make a WEB-INF folder and under it classes
folder. In WEB-INF we have to write web.xml .
Our compled servelet class file should be stored in classes
folder.
Make a war file using jar & deploy in Web.
| Is This Answer Correct ? | 97 Yes | 27 No |
Answer / anji
The structure of the web app. is
demo[root]
- all jsps will go her
- WEB-INF
- web.xml
- tld files
- classes
- all java class files will go here
Compile all the files and create a war file
copy the war file into Tomcat_root\webapps folder
if you use weblogic or webspehere the deployment will be
different.
| Is This Answer Correct ? | 41 Yes | 28 No |
Answer / suresh
we have make dir name is,WEB-INF is the root directory
WEB-INF
--classes dir
--lib dir
--src dir
--web.xml
-html file
-dhtml file
-jsp file
lib dir contains
--jasper-runtime.jar
--servlet-api.jar
--jsp-api.jar
your source code put in the src dir
--put the WEB-INF dir in your tomcat server and run the servlet
| Is This Answer Correct ? | 27 Yes | 15 No |
Answer / kunal sagar
first we con compile the java code throught javac compiler.
then,its .class file will be created that .class file copy
and paste the in the directory
c:/program files/apache/tomcat/webapps/servlet/web-inf
/classes.
then back one step backward
change the servlet code with ur file name
and also sevlet mapping code with ur file name
save that file
then open explorar
and type the local host address
| Is This Answer Correct ? | 18 Yes | 6 No |
Answer / vivek
To run a servlet one should follow the steps illustrated below:
Download and Install the tomcat server: Install the tomcat server in a directory in which you want to install and set the classpath.for the variable JAVA_HOME in the environment variable. To get details about the installation process and setting the classpath click the link Tomcat installation.
Set the class for the jar file: Set the classpath of the servlet-api.jar file in the variable CLASSPATH inside the environment variable by using the following steps.
For Windows XP,
Go to Start->Control Panel->System->Advanced->Environment Variables->New button and Set the values as
Variable Name: CLASSPATH
Variable Value: C:\Program Files\Java\Tomcat 6.0\lib\servlet-api.jar
For Windows 2000 and NT
Go to Start->Settings->Control Panel->System->Environment Variables->New button and Set the values as
Variable Name: CLASSPATH
Variable Value: C:\Program Files\Java\Tomcat 6.0\lib\servlet-api.jar
Create a java source file and a web.xml file in a directory structure.
Compile the java source file, put the compiled file (.class file) in the classes folder of your application and deploy the directory of your application in the webapps folder inside the tomcat directory.
Start the tomcat server, open a browser window and type the URL http://localhost:8080/directory (folder name of your application) name/servler name and press enter.
If everything is correct your servlet will run.
| Is This Answer Correct ? | 8 Yes | 5 No |
Answer / anil reddy
WEB-INF
--classes dir(.class)
--lib dir
--src dir(.java)
--web.xml
-html file
-dhtml file
-jsp file
=>tomcat on and goto browser type your html name(http:
\\localhost:8081\.html)
| Is This Answer Correct ? | 10 Yes | 10 No |
Sampleapplication
-- any html or jsp pages
-- WEB-INF
--web.xml
--lib(which contains any jar files)
--classes
--(all Servlet .class files)
After compilation of Servlet .java files start the Tomcat
Server and in URL type like:
http://localhost:8080/Sampleapplication/.html(or).jsp <--(enter)
| Is This Answer Correct ? | 5 Yes | 6 No |
Explain the difference between servletconfig and servletcontext in servlet?
What is servlet context ?
Hi............ When i am started the tomcat server it started. but it not load the jar files wht we deploving file.suppose we load the wapp folder in webapps. At running time it show the below error in tomcat server INFO: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 5.0\web apps\wapp\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, s ection 9.7.2. Offending class: javax/servlet/Servlet.class How to slove this problem in my system. plz give answer for this problem.
What do you mean by web applications?
What do you mean by mime type?
If you want to modify the servlet,will the Webserver need to be ShutDown ?
Why is servlet used?
What is servlet in tomcat?
What are the mechanisms used by a servlet container for maintaining session information?
What’s the difference between forward() and sendredirect() methods?
What is session tracking?
What is load-on-startup in servlet?