Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


RAHUL
how to compile and run servlet program
2 Answer(s)      3 years 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


Advertisement
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
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 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 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 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 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: http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml http://www.roseindia.net/servlets
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
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 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 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
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
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 Java program in CMD
discussed how to write and run Java program in CMD. Tips to run Java program... it should compile the file.  Now time to execute the program. Run...\bin Now time to compile your program. Write the following command to your
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 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 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
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 write servlet program in eclipse?
how to write servlet program in eclipse?  how to write servlet program in eclipse
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
compile
compile  how to compile .class files using eclipse
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 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 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
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
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  
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 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
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
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
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
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I need ANT? If so, please give instructions. I am a student. http
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 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 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 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
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
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><
why java program not run with msword editor
why java program not run with msword editor  if java program write in MICROSOFT WORD then why they are not run with jdk
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
how to run a vlc player in jsp
how to run a vlc player in jsp  how to run a vlc player in jsp
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
 

 

 

DMCA.com