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



Home Answers Viewqa JSP-Servlet servlet programe

Have Programming Question? Ask it here!
 
 
 


sureshreddy
servlet programe
1 Answer(s)      3 years and 7 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
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  How many times the servlet is accessed
servlet
servlet  is there any way to include pdf's in servlet
servlet
servlet  what are the methods and interfaces in the servlet api ?   Servlet Tutorials
servlet
servlet  what are the all necessary configuration to run a servlet
servlet
servlet  how to interact with a servlet from a swing program
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
Java - JSP-Servlet
Java  What a the steps to compile a Servlet Programe.  Hi... to configure tomcat for running servlet. http://www.roseindia.net/servlets/HowToRunAServlet.shtml After configuring servlet API path to compile the Servlet path
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
Servlet  What must be implemented by all Servlets?    The Servlet Interface must be implemented by all servlets
servlet
servlet  i want a program for counting the no of times the servlet has been invoked
Servlet
Servlet  I want to know the steps to write a simple servlet program... .   Hello Friend, Follow these steps: Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet. import java.io.*; import
Servlet
Servlet   Why is Servlet so popular?   Because servlets are platform-independent Java classes that are compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology-enabled Web
servlet
servlet  i want to use servlet application on my web page then what should i do. I have already webspace.   Hi Friend, Please visit the following link: Servlet Tutorials Thanks
servlet
servlet  how to read a file from different folder using filereader in servlet   Hello Friend, Please visit the following link: http://www.roseindia.net/servlets/servlet-read-file.shtml Here you will get an useful
Servlet
Servlet  Can a user defined function be included in a servlet? I need information regarding servlet syntax and not JSP.   Yes, you can create user defined function in Servlets. Have a look at the following link: http
servlet
servlet   Dear Deepak, is it compulsary to write the sevice() becoz i ve seen some example which does not ve sevice()..is it tue? plz replay me with thanks praveen
servlet
servlet  plz can anyone give me the link of javax library jar file. i badly need that. thanks in advance   Please visit the following link: Download Servlet API
servlet problem - Servlet Interview Questions
servlet problem   when i have perform action on submit button then there is no call servlet in my action i have done every effort in this programe... application folder and servlet in classes folder of apache tomcat. The web application
Servlet
the same error <web-app> <servlet> <servlet-name>InsertServlet</servlet-name> <servlet-class>InsertServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>
servlet
servlet file which prints out the user's inputs. I need to use the post method to pass the data from html to the java servlet and also use both doGet and doPost methods in the servlet. I think, but unfortunately I have a terrible teacher
servlet
to servlet. So, if anyone can help me so I can see how to connect the two I would
servlet
servlet  How do we define an application level scope for servlet?   Application scope uses a single namespace, which means all your pages should be careful not to duplicate the names of application scope objects
servlet
servlet  how to jsp integer are type cast int servlet page   Hi Friend, Try the following code: 1)form.jsp: <form method="post" action="../Data"> Enter Number:<input type="text" name="num" > <input
servlet
); } } } this is the code for .java servlet am able to run
on servlet - JSP-Servlet
on servlet deployment  What we'll get on servlet deployment
Servlet - JSP-Servlet
Servlet and Java Code  Example and source code in Servlet and JSP
servlet Service
servlet Service  Defined servlet Service
servlet initialization
servlet initialization  define servlet initialization
Servlet Context
Servlet Context  Defined Servlet Context
servlet container
servlet container  What is servlet container
Servlet chaining
Servlet chaining  What is Servlet chaining
servlet - Servlet Interview Questions
Servlet Priority  How to set priority for servlet?  in web.xml file we can set priority of servlet. 1 2
servlet - Servlet Interview Questions
servlet  what is the full form of servlet
servlet - Servlet Interview Questions
servlet  what is the full form of servlet
java (servlet) - JSP-Servlet
java (servlet)  how can i disable back button in brower while using servlet or JSP
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
servlet as final - JSP-Servlet
servlet as final  whether we can declare final for a servlet or not? and give the reason
Servlet Question - JSP-Servlet
Servlet Question  I want to call one servlet when the browser window is closed by User
servlet - JSP-Servlet
servlet navigation problem  Hi, i am facing problem in Servlet navigation
servlet code - JSP-Servlet
servlet code  Create a servlet to develop a login application with javascript clientside validations and serverside validations
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
Advertisements
 

 

 

DMCA.com