Friday 21 June 2013

10.Write a Servlet to display “Hello World” on browser.

WTAD Practical - 10
Write a Servlet to display “Hello World” on browser.
WEB-INF/web.xml


<web-app>
<servlet>
<servlet-name>s10</servlet-name>
<servlet-class>Hello</servlet-class>
</servlet>
<!-- Servlet Mapping -->
<servlet-mapping>
<servlet-name>s10</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>


WEB-INF/classes/Hello.java


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Hello extends HttpServlet
{
public void service( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<HTML>" +
"<HEAD><TITLE>WTAD.practical-10 @iAmLearningHere</TITLE></HEAD>" +
"<body bgcolor=YellowGreen>" +
"HELLO WORLD" +
"</body></HTML>");
}
}

Preview

How to Run?
> Start Apache Server
> Start localhost and open program folder
> type url '/hello'


For all WTAD programs wtad-pra cticals.html
To get all programs in your inbox.Enter your email

Kindly Bookmark and Share it:

0 comments :

Post a Comment

Any Query ? any suggestion ? comment here

 

Recent Post

Recent Comments

© 2010 IamLearningHere Template by MBT