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



Home Answers Viewqa JSP-Servlet servlet programe
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sureshreddy
servlet programe
1 Answer(s)      3 years and 11 months ago
Posted in : JSP-Servlet


import java.io.*;
import javax.servlet.*;
public class Helloservlet extends GenericServlet{
{
public void service(ServletRequest request, ServletResponse response) 
throws ServletException , IOException
{
    String msg="HelloWorld";
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    out.println("<HTML>");
    out.println("<BODY BGCOLOR=GREEN>");
    out.println("&lt;H1>"+msg+"</H1>");
    out.println("</BODY>");
    out.println("</HTML>");
    out.close();

}
}
}

Advertisement
View Answers

January 25, 2011 at 5:36 PM


Hi Friend,

Try this:

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>");
  }
}

For more information, visit the following:

Servlet Tutorials



Related Tutorials/Questions & Answers:
servlet programe
servlet programe  import java.io.*; import javax.servlet.*; public class Helloservlet extends GenericServlet{ { public void service... the following: Servlet Tutorials
java programe - Java Beginners
java programe  write a java programe to compute n! for any number. 1! 2!=2*1 3!=3*2*1 n!=n*(n-1)(n-2)   //int type is limited so if you wish to extend the value just change the data type.. =) import java.io.
Advertisements
java programe executing error - Java Beginners
java programe executing error  i am creating one package to one class, but the compilation is succeed but how to execute the class  Hi Friend, If you have following java class: package newp; class Hello
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered...-Servlet/9584-JSP-Servlet-Search-and-Edit.html http://www.roseindia.net/jsp
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered...-Servlet/9584-JSP-Servlet-Search-and-Edit.html http://www.roseindia.net/jsp
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered...-Servlet/9584-JSP-Servlet-Search-and-Edit.html http://www.roseindia.net/jsp
How can i implement the calculator programe in jsp code
How can i implement the calculator programe in jsp code  Please send code for the calculator using jsp technologies please guidelines to me.   Here is a simple jsp calculator code that accepts two numbers from the user
code to enter values in multiple textfields throught 10 buttons (0-9) (as if a calculator programe)
code to enter values in multiple textfields throught 10 buttons (0-9) (as if a calculator programe)  how can i enter values in two different textfield's through 10 different buttons.?? as we saw a online calculator type
Servlet
Servlet  What is Servlet
Servlet
Servlet  how to navigate one servlet page to another servlet page
error message - JSP-Servlet
error message  hi, friends after complete my servlet programe i can type http://localhost:8080 on the browser. the servlet program is insert data into dbms. but i have errormessage that is "window can not access the specified
servlet
servlet  is there any way to include pdf's in servlet
servlet
servlet  How many times the servlet is accessed
servlet
servlet  what are the methods and interfaces in the servlet api ?   Servlet Tutorials
servlet
servlet  how to interact with a servlet from a swing program
servlet
servlet  what are the all necessary configuration to run a servlet
servlet
servlet  i want to create a login page with servlet using database mysql? only in servlet not in jsp plzz help me out
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
Servlet
override Service method in the servlet when you extend GenericServlet to create servlet as it is mandatory to override it. But, when you extend HttpServlet to create a servlet then you can't override service method as there is a need to override
servlet
of the Servlet API. It contains the classes necessary for a standard, protocol-independent servlet. Every servlet must implement the Servlet interface in one
servlet
servlet  can i stoar record in variable which selected from table in servlet
servlet
servlet  dear sir servlet and html not run on eclips plz help me
servlet
servlet  how to create a login form using servlet using submit,edit delete button
servlet
servlet  i want a program for counting the no of times the servlet has been invoked
Servlet
Servlet  What must be implemented by all Servlets?    The Servlet Interface must be implemented by all servlets
 

 

 

DMCA.com