How to run a servlet program?

Answers were Sorted based on User's Feedback



How to run a servlet program?..

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

How to run a servlet program?..

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

How to run a servlet program?..

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

How to run a servlet program?..

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

How to run a servlet program?..

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

How to run a servlet program?..

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

How to run a servlet program?..

Answer / giridhar gangapatnam

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

Post New Answer

More Servlets Interview Questions

What are the kinds of http requests?

0 Answers  


Hi frnds iam new to Java Kindy any one can provide or me Servlets Example code and can explain to me flow of servlets and as Jsp and Struts and provide to me some sample example on these 3 topic flow,code example,and tutorials,and related websites which i can refer....thanks in advance..........

3 Answers  


Explain the servlet context.

0 Answers  


What are the servlet events?

0 Answers  


Tell the new features added in servletrequest interface i.e. Servlet 2.4

0 Answers  






what is meant by Transaction Isolation Levels?

2 Answers   IBM,


How can you run a servlet program?

0 Answers  


What do you mean by cgi and what are its drawbacks?

0 Answers  


What is forward() and include() of servlets RequestDispatcher interface?

6 Answers   HCL,


How can a servlet be used to generate plain text instead of html?

0 Answers  


Name the servers that can be used to develope and deploy Servlets?

1 Answers  


What advantages do servlets have over CGI programs?

5 Answers  


Categories