advance java question

advance java question

how to develop servlets without using any IDE such as netbeans..

View Answers

December 23, 2010 at 4:35 PM

Hello Friend,

Follow these steps:

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.

<web-app>
 <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>
</web-app>

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/webapplicationfoldername/HelloWorld

For more information, visit the following links:

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

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

Thanks









Related Tutorials/Questions & Answers:
advance java question
advance java question  how to develop servlets without using any IDE such as netbeans..   Hello Friend, Follow these steps: Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet. import
advance java
advance java  application to demonstrate email validator
Advertisements
advance java
advance java  i want to refer advanced java book can u plz suggest me auther name   You can learn from the following books: 1)Advanced Java, Gajendra Gupta 2)Core servlets and JavaServer Pages,Marty Hall
advance java
advance java  give the sourse code for sky high institute of management using j2ee
Advance Java
Advance Java  Context ctx = new InitialContext(); if(ctx==null) { throw new RuntimeException("JNDI Context not Found"); } ds=(DataSource)ctx.lookup
advance java
advance java  what is servlet context?why its used?in what situation we should use it in our program?   Hi Friend, ServletContext is an interface that is defined in the javax.servlet package. It describes a set
Advance Java Training Program
Advance Java Training Program  Hi, Can anyone guide me how to study advance Java in few day's  Please visit the following link: Java Tutorials Through the above link, you will get the links of advanced java tutorials
Advance and Core JAVA Topics
Advance and Core JAVA Topics  topics come under core java and topics come under advanced java?   Under Core Java, following topics comes... JDBC Under Advanced Java, following topics comes: Generics Reflection
Advance Java training topics
Advance Java training topics     ... simple JSPs that use Java code in declarations, expressions and scriptlets... Java exception handling and JSP error pages to handle errors   
Online Advance Java Training Course
Online Advance Java Training Course Online Advance Java Training Course... describes how the advance Java is important for any software company, its future and the advance technologies which are important to learn with core Java
Question in Java ??
Question in Java ??   Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number squrfoot
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Question on java
Question on java  why java is not purely oop?   java is not purely OOP because 1.) Multiple Inheritance is not supported.ADS_TO_REPLACE_1 2.) It uses primitive data type. 3.) static method can be called without
Question Java>?
Question Java>?  **ïâ??· Create a new class called Bank and in the main method use class Account (lab 4) to create an array of 10 accounts. ïâ??· Enter data for all accounts (account number,name, balance). ïâ??· Add
java question
java question   Create a class called Complex to perform arithmetic operations with complex numbers. 1- Use double variables to represent the fields of the class. 2- Provide a no-argument constructor with default values in case
java question :)
java question :)  write java program to use vector in ArrayList with add, remove,sort   import java.util.Vector; public class... Element MUAYAD"); vc.add("Vector Element JAVA"); vc.add("Vector Element
java question
java question  the purpose of defining multiple constructor in java
java question
java question  find the 127 twin pair in java
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
java question
java question  what is the difference between path and classpath in java
JAVA QUESTION
JAVA QUESTION  How to view image on Frame in swing(or)awt in Java
java question
java question  How to find the longest and shortest line from the file in case of java and java program should read the filename from the keyboard
java question
java question  wats dynamic dispatching
java question
java question  Please, give me sample program for insert Audio(sound) on Frame in swing in java
java question
java question  how to write a java program that, given a friend name , display the phone number and the email address for that friend
java question
java question  anyone provide the code to call c++ function from java   Here you will find details how to implement the c++ into the java. http://www.javaworld.com/javatips/jw-javatip23.html
Java Question
Java Question  can u give me one expample in which conditions we... in java includes only abstract methods i.e. methods have signatures only (or we... in java defines that it must be implemented by any class to make use of it. One
java question
java question  input any number and check if sum of alternate digit is palindrome
java question
java question  what are the exactly J2EE concepts.. struts and hybernates coming under which catagiry
java question
java question  i wrote to java code to get data populated in the Revision field of table InventDim 2.Failing to successfully do the above, i tried to use the ConfigId field of table InventDim for the same purpose, by labeling
java question
java question  how to create date and time based pgm in java... in db table if date and time crossed automatically update in the db and inform to login user as pop ups   http://www.roseindia.net/jsp/loginstatus.shtml
java question
java question  Can any one send me the source code to get confirmation after the successful registration to our mobile
java question
java question  when we use the Abstract class and interface?   Please visit the following link: Abstract class and Interface
java question
java question  sir, can you give me the code for online banking using netbeans and mysql in j2ee with its database connectivity
java question
java question  sir, can you give me the code for online banking using netbeans and mysql in j2ee with its database connectivity
java question
java question  I am converting a .net website into java one. Can you help me how to code things step by step. project name - src -java -main -webapp - common - jsp - css - images - javascripts I
java Question
java Question  write a program that reads an integer and check whether it is even. for example, if your input is 25, the should be: is 25 an even number? false if your input is 2000, the should be: is 2000 an even number?true
Java question
Java question  Write a program that converts a (C to F Converter from 0 - 20) and writes the output to a file instead of the screen. Open the file in Notepad to confirm the output
java Question
java Question  write a program that reads an integer and check whether it is even. for example, if your input is 25, the should be: is 25 an even number? false if your input is 2000, the should be: is 2000 an even number?true
java question
java question  i have a string like "My name is arvind.i live in bangalore.i study in college.".the problem is that i hav to break this string into three seperate lines
java question
java question  comparator and comparable   Differences: a)A comparable object is capable of comparing itself with another object while...: http://www.roseindia.net/help/java/c/comparable-interface.shtml http
java Question
java Question  use nested loops that print the following patterns in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4
java Question
java Question  use nested loops that print the following patterns in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4
java Question
java Question  use nested loops that print the following patterns in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4
java Question
java Question  use nested loops that print the following patterns in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4
java Question
java Question  use nested loops that print the following patterns in four separate program. Pattern1 1 12 123 1234 12345 123456 Pattern2 123456 12345 1234 123 12 1 Pattern3 1 21 321 4321 54321 654321 Pattern4
java question
java question  Hello sir/mam, In collection there is method called toArray() which is used to convert collection into array at tat time array is used 2 store diffferent objects,how is it possible can you describe it briefly
java question
java question  Hello sir/mam, In collection there is method called toArray() which is used to convert collection into array at tat time array is used 2 store diffferent objects,how is it possible can you describe it briefly

Ads