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

Difference between httpservlet and generic servlets?

0 Answers  


What are common tasks performed by Servlet Container?

0 Answers  


What is the default HttpRequest method?

6 Answers  


How do you track a user session in servlets?

3 Answers  


Explain how does JSP handle run-time exceptions?

0 Answers   BirlaSoft,






What are the supporting protocol by HttpServlet ?

0 Answers  


Which method is called when reference variable is passed in system.net?

0 Answers   HCL,


Explain the differences between jsp and servlet.

0 Answers  


Explain the architechure of a servlet?

0 Answers  


What is servlet name in web xml?

0 Answers  


Can we use javascript in Servlets?

2 Answers   Wipro,


What do you mean by servlet?

0 Answers  


Categories