how to compile and run servlet program

how to compile and run servlet program

hello sir/mam i hve installed tomcat5.5 version and also have jdk1.6.0_14 installed but not able to run it or compile i m doing it first tyme pls help me in sorting out this problem. i hve seen rose india tips but not getting it pls help me

View Answers

July 19, 2011 at 4:01 PM

Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet{ 
  public void doGet(HttpServletRequest request, HttpServletResponse response)
                                   throws ServletException,IOException{
    response.setContentType("text/html");
    PrintWriter pw = response.getWriter();
    pw.println("<html>");
    pw.println("<head><title>Hello World</title></title>");
    pw.println("<body>");
    pw.println("<h1>Hello World</h1>");
    pw.println("</body></html>");
  }
}

2)Go to the webapps folder of your apache tomcat and create a web application folder but it should having an appropriate name like examples.

3)Create web.xml and classes folder inside the WEB_INF folder of web application folder.

4)Copy the servlet to the classes folder.

5)Edit the web.xml to include servlet?s name and url pattern.

  <servlet>
  <servlet-name>HelloWorld</servlet-name>
  <servlet-class>HelloWorld</servlet-class>
 </servlet>
 <servlet-mapping>
 <servlet-name>HelloWorld</servlet-name>
 <url-pattern>/HelloWorld</url-pattern>
 </servlet-mapping>

6)Compile your servlet.

7)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.

8)Open the browser and type the following url:

http://localhost:8080/webapplicationfolder_name/HelloWorld

For more information, please go through the following links:

http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml

http://www.roseindia.net/servlets/HowToRunAServlet.shtml


April 29, 2012 at 1:08 PM

1)Normal command prompt programin

javac -classpath ".; D:\xampp\tomcat\lib\servlet-api.jar"

D is my driver path can you install to other driver

2) another is easy to compiling system, it using programmer notepad (this system can using for java compiling)

Download for this link (open and free)

following this step

1) Open PP

2) Tool -> option -> select tool tab

3) Select language java to upper tab

4) Selecting add button

5) Filling form

6) Name :- Servelt

Command:- E:\Program Files\java\jdk1.6.0_25\bin\javac.exe // JDK javac path

Folder :- C:\java // your using or file folder

Parameter :- %f -classpath ".;D:\xampp\tomcat\lib\servlet-api.jar"
// this copy and paste and changing a driver Ex:- D

Shortcut:- F12 // selecting you lick button

Save:- current file // or you lick

After Ok 1 view -> output or press F8 Ok finish Coding after press F12









Related Tutorials/Questions & Answers:
how to compile and run servlet program
how to compile and run servlet program   hello sir/mam i hve installed tomcat5.5 version and also have jdk1.6.0_14 installed but not able to run it or compile i m doing it first tyme pls help me in sorting out this problem. i hve
How to compile and run Java program
How to compile and run Java program  How to compile and Java program..., For compiling and running the Java program from command prompt you should must have JDK... tutorial Compiling and Running Java program from command line. If Java
Advertisements
compile and run java program
_TO_REPLACE_1 how do I compile and run this file using the terminal of ubuntu...compile and run java program  Hello, everyone!!! I just want to ask if you anyone here knows how to compile java file in linux specifically UBUNTU
How to Develop, Compile & Run a rmi Program in NetBeans 6.9.1 ide?
How to Develop, Compile & Run a rmi Program in NetBeans 6.9.1 ide?  how to develop, compile & run a rmi program in netbeans 6.9.1 ide? will you please give me a step by step (practical) explaination? Thanks in advance
How to compile and run the JSP
How to compile and run the JSP  Hi Kindly tell me how to run and compile JSP small Program using Tomcat as webserver. I created small program HELLO JSP in HTML and compile the program but it is saying Class o r interface
how to run jdbc in jsp program - JSP-Servlet
how to run jdbc in jsp program  i want to use sql server 2005 in jsp program to store data.i know how to run simple program but this program i tried my best i am not able to do so.please give me the answer of this as soon
how to run servlet - JSP-Servlet
how to run servlet  pls give me comlete procedure to run the servlet on apache-tomcat 6.0.16 how can i set my classpath, java_home etc. also where i have to save my servlet program and how it compile and then run on web browser
how to compile and run struts application - Struts
how to compile and run struts application  how to compile and run struts program(ex :actionform,actionclass) from command line or in editplus 3
how to run rmi program
how to run rmi program  how to run rmi program
how to run this program?
how to run this program?  how to run java swing program   Java Swing program runs same as a simple java program. There is no difference... with javac and run with java command, same as a simple java program. Learn Swing
how to run java program
how to run java program  i have jar file. in jar i have so many classes.in one of file i want modify .after modifying file i want replce in jar. please help me to how to generate class and how to replace
how to run servlet
how to run servlet  Servlet run procedure for J2EE Software   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml http
How to run JSP program inEclipse?
How to run JSP program inEclipse?  Hi, I am learning JSP. I want to run JSP in Eclipse. How to run JSP program inEclipse? Thanks   Hi, Its easy to run JSP from the Eclipse. You have to make a dynamic web application
How Jdbc program can be run??
How Jdbc program can be run??  import java.sql.*; import java.util.... is the problem? and how can i run it successfully? please give me a satisfieng answer... created successfully and when i compiled this program then it compiled successfully
How to Run First Java Bean Program ?
How to Run First Java Bean Program ?  Hi My Dear Friend I can run... But Now I need that How to run Java Bean Now I have BDK1.1 But still don't know that how run this... I have this bdk dir... \bdk1_1\beans\beanbox
how to write servlet program in eclipse?
how to write servlet program in eclipse?  how to write servlet program in eclipse
how to run a java program using run.exec()?
how to run a java program using run.exec()?  Hi..i want to compile and run a java file using run.exec().i.e., without compiling and running from command prompt i want to do them in the program itself.I am able to compile
how to run jdbc program in linux-ubuntu?
how to run jdbc program in linux-ubuntu?  how to run jdbc program in linux-ubuntu?   hi firstly download the jdk on your system using... to compile java program javac prog.java java prog
how to run jdbc program in linux-ubuntu?
how to run jdbc program in linux-ubuntu?   how to run jdbc program in linux-ubuntu
How to run program in new opened cmd
How to run program in new opened cmd  Hello i have made a program in java to open command prompt, then how to run my left of the program in the new opened command prompt
Unable to compile Servlet
was created by me. To compile my servlet program I did the following: C:\apache...Unable to compile Servlet  First I installed the tomcat server in C... JAVA_HOME with the value C:\Program Files\Java\jdk1.6.0.14 Then I created
How to run a servlet
How to Run a Servlet       To run a servlet one should follow the steps illustrated below:  Download...; Variable Value:  C:\Program Files\Java\Tomcat 6.0\lib\servlet
servlet not compile - Java Beginners
servlet not compile  Hi friend, I am Using JDK 5.0 with that javax.servlet is not available so i download this package and put it in the src folder,but my program displayed "package not found" at the time of compilation
How to run a Java program in CMD
discussed how to write and run Java program in CMD. Tips to run Java program...\Java\jdk1.5.0_09\bin Now time to compile your program. Write the following... the program. Run the given command. C:\myproject> java HelloWorldADS_TO_REPLACE_2
how to deploy and run jsp - JSP-Servlet
how to deploy and run jsp  hi anybody plz tell how to deploy and run... in the root directory . If you run on localhost then in browser file "abc.jsp" deploy in the root directory and run with this URL http://localhost
How to run JSP program in Tomcat server step by step?
How to run JSP program in Tomcat server step by step?  Hi, I am trying to run the JSP and looking for the quick example that will teach me to run.... How to run JSP program in Tomcat server step by step? Thanks   Hi
how to ruv servlet program in myeclipse blue edition?
how to ruv servlet program in myeclipse blue edition?  how to ruv servlet program in myeclipse blue edition?  Servlets are run in a web server. The servlet can be deployed to the web server as part of deploying your
unable to run servlet
-mapping> 6)Compile your servlet. 7)Run Tomcat server by clicking...-mapping> 6)Compile your servlet. 7)Run Tomcat server by clicking the startup.bat...-pattern>/HelloWorld</url-pattern> </servlet-mapping> 6)Compile your
how to connect j2me program with mysql using servlet?
how to connect j2me program with mysql using servlet?  my program...(a); } }; } servlet program is: import java.io.... = new Thread(this); t.start(); } public void run
couldnt run this program
couldnt run this program  package calculator; import java.util.Scanner; public class calculator{ public static void main(String args[]){ Scanner vin = new Scanner(System.in); Double firstnum,secondnum,sum,sub,mul
How Run JSP in Apache TomCat Server? - JSP-Servlet
How Run JSP in Apache TomCat Server?  How to Run JSP in Apache Tomcat Server? I have getting Jasper Exception which says class not found i have... program there. You can also check compete tomcat tutorial at http
i got an error while compile this program manually.
i got an error while compile this program manually.  import javax.servlet.http.*; import org.apache.struts.action.*; public class ActionOne{ public... mapping.findForward("errors.jsp"); } } i set both servlet
how to compile programs??????????
how to compile programs??????????  "javac" is not recognised as a file name. why??????????   Have you set your path name and class name correctly? Anyways have a look at the following link: Install Java
servlet program - JSP-Servlet
servlet program  Hi All, I just want to write a servlet program where in i want to retreive some data(some names) through a sql query from a sql... the servlet is executed .can you please send me the code? I hope my requirement
compile this program and let me know the resolution
compile this program and let me know the resolution  class Maxof2{ public static void main(String args[]){ //taking value as command line...+" is greater than "+i); } } please compile and let me know the resolution  
java program run on thml page?
java program run on thml page?  how to run java program on html page using text area
unable to compile class file - JSP-Servlet
unable to compile class file  I wrote database connection in jsp file.... In database i have a employeeid field. How can i display all employee id in that dropdown list box.   Hi, dynamic bombobox in servlet
JSP and Servlet did not run - JSP-Servlet
JSP and Servlet did not run  I tried to run this program but when I... --------- Simple Use of Servlet and JSP...; Hi Friend, Put your servlet in WEB-INF\classes folder and do
compile
compile  how to compile a java program using jre7
How to save run time created text-file on a disk using jsp/servlet?
How to save run time created text-file on a disk using jsp/servlet?  I have a JSP page with save button.In that I created the file(e.g a.txt) at run-time,when I click on the save button,it will ask where to save the file
how to run java program that has several classes under package from usb drive?
how to run java program that has several classes under package from usb drive... package. I have to use following line on command line to compile and run my program... and run the code. I tried installing jdk but it was taking very long time so did
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... by using servlet or jsp program by typing the output as like this below.... Actual problem is that i have a simple program in jsp in the sense to get data
Example to compile a java file with the help of the program
Example to compile a java file with the help of the program... are describing you the way to compile the java file with the help of the java program. The steps involved for compiling the java file from the program are described
How to Program in Java
This tutorial tells you how to program in Java? As a beginner you must know... world (First java program) for more details on "How to Program in Java?". Create... the program. This is the final step of testing the Java program. Here it will run
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
How to compile & get output for JSP
How to compile & get output for JSP  HI My Roseindia friend has given the answer as RUN the JSP How to run the JSP Program? But what i mean is that i created a small jsp program in HTML and saved as Hello.jsp. And next i opened
compile
compile  how to compile .class files using eclipse
servlet program problem - Java Beginners
servlet program problem   i used ur servlet example prg with xml file of helloworld program and i run dat program in tomcat, it shows only... the code alone, reply me how to run or whether i hav to create a separate html
jsp/servlet login program
; </html> When I run the program, I get an error: The requested resource...jsp/servlet login program  <%@ page language="Java" import="java.sql.*" %> <HTML> <HEAD><TITLE>DataBase Search<
problem in servlet program
problem in servlet program  Dear Sir, I have a problem to insert the Blob type data like as video file, audio file in the database using Servlet and html code

Ads