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



Home Answers Viewqa Java-Beginners advance java question
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Robin Sharma
advance java question
1 Answer(s)      4 years ago
Posted in : Java Beginners


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


Advertisement
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  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
Advertisements
advance java
advance java  application to demonstrate email validator
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   
Advance DBMS
Advance DBMS  What are views? Explain its various types?   Hi, Database allows us to create abstract form of the data from different tables. This is done through views. Read how to create view at Views in SQL
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. 2.) It uses primitive data type. 3.) static method can be called without creating instances
Advance Java Training
Advance Java Training      ... simple JSPs that use Java code in declarations, expressions and scriptlets... Java exception handling and JSP error pages to handle errors. 
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  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  How to view image on Frame in swing(or)awt in Java
java question
java question  find the 127 twin pair in java
java question
java question  the purpose of defining multiple constructor in java
java question
java question  what is the difference between path and classpath 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  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  Please, give me sample program for insert Audio(sound) on Frame in swing in java
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  what are the exactly J2EE concepts.. struts and hybernates coming under which catagiry
Advertisements
 

 

 

DMCA.com