Home Answers Viewqa Servlet-Interview-Questions how to compile and run servlet program

 
 


RAHUL
how to compile and run servlet program
2 Answer(s)      a year and 10 months ago
Posted in : Servlet Interview Questions

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 Pages:
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
compile and run java program
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... do I compile and run this file using the terminal of ubuntu... By the way, I am
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 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
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 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 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 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
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 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
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
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 - Java Beginners
how to run   how to run java program... brifely  Hi... the "javac" command to compile the program and after compiling,uses "java" command to execute or run the program. For ex, If you have the following java program
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 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
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 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 servlet
how to run servlet  Servlet run procedure for J2EE Software   Hi Friend, Please visit the following links: http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml http://www.roseindia.net/servlets
How to run a simple jsp page in tomcat???
How to run a simple jsp page in tomcat???  i am trying to run...\Tomcat 6.0\lib\servlet-api.jar using this ,i am able to run all servlet programs... org.apache.jasper.JasperException: Unable to compile class for JSP: An error
Compile time error
Compile time error  Hi, When i compile my simple program in cmd am getting a error like "Javac is not a recognized as an internal or external command, operable program or batch file" How to resolve this problem ????  
How Jdbc program can be run??
How Jdbc program can be run??  import java.sql.*; import java.util.... ,but when i run it ,it gives following error-> C:\Program Files\Java... to know what is the problem? and how can i run it successfully? please give me
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
SOLUTION: How to compile Objective C on Windows with GNU Step ?
SOLUTION: How to compile Objective C on Windows with GNU Step ?  <..., except the fact that the above program needs some more instructions to run. Here...;<strong>Compile using the below mentioned command line:</strong><
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 run jdbc program in linux-ubuntu?
how to run jdbc program in linux-ubuntu?   how to run jdbc program in linux-ubuntu
How to Program in Java
This tutorial tells you how to program in Java? As a beginner you must know... program) for more details on "How to Program in Java?". Create simple... of testing the Java program. Here it will run on the JVM. To run the java
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 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
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
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
java pages run
java pages run  how do we run jsp file in the browser. do we need to install server. could it be run on the xamp server   You need Apache Tomcat Server to run the jsp code over it. Follow these steps to run the simple
New to JSP..need help to make & run a JSP program.
New to JSP..need help to make & run a JSP program.  Hi, I have installed Tomcat 5.5 on my system. Plz help me to make a simple JSP program. And also how to run it.   Hi Friend, Have you set the classpath? Anyways
How to run? - Hibernate
How to run?  Hiiiiiiiiiiiii friend.. i am Magesh, doing MCA at Madurai in Tamilnadu. i know little bit about Jsp,Servlet.. But my friends are told hibernate is a new entry to Java. so plz try to tell how to use
how to run applet - Applet
how to run applet   Hi everybody i am using connecting jdbc in applet program. this is executed successfully with appletviewer command >... how can i execute in browser ? Thanks in advance thanks for seeing my
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
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 download, compile and test the tutorials using ant.
;     In this section we will learn how to download and run Struts 2.1.8 examples discussed here. You will have to install ant build tool to compile the examples. You can go to the command prompt and type
compile error
program with Test.java and try to compile with javac test.java an error like...compile error  Hello All for example public class..."); } } i have save this program with A.java. Then I executed this program javac A.java
First Java Program
HelloWorld.java Learn how to compile and run Java File at http://www.roseindia.net...; In this section you will learn how to develop your first Java program and then compile and test the same on your development machine. Write first Program
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 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
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.*; import java.util....(this); t.start(); } public void run
how to write servlet program in eclipse?
how to write servlet program in eclipse?  how to write servlet program in eclipse
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
Objective C on Mac
; I this section we will show you how to compile and run Objective C program on Mac machine. Compiling Objective C on Mac OS x To Compile Objective-C Programs on Mac OS X This is a simple process to compile and run the code. Follow
java not run on my pc
java not run on my pc  i have installed java in pc but when i run and compile any program the massage is display that 'javac' is not recognized as an internal or external command
Servlet
Servlet  I want to know the steps to write a simple servlet program on windows without using any IDE and steps to run...please send me clear steps...-pattern> </servlet-mapping> </web-app> 6)Compile your servlet. 7
HOW TO RUN JDBC PRORAM ON JDK1.5.0
HOW TO RUN JDBC PRORAM ON JDK1.5.0  import java.sql.*; import... driver specified i want to know what is the problem? and how can i run... this program i am using jdk1.5.0`*print("code sample");*` I have created Dsn
How to run our application after deploying .war file in tomcat6.0
How to run our application after deploying .war file in tomcat6.0  How to run our application after deploying .war file in tomcat6.0?   Hi...-tomcat lib as a value like C:\apache-tomcat-6.0\lib.*; 3)Also put the servlet
j2me pgrm run
j2me pgrm run  How to run a j2me program   Please visit the following link: J2ME Tutorials

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.