WTAD Practical - 10
Write a Servlet to display “Hello World” on browser.
WEB-INF/web.xml
WEB-INF/classes/Hello.java
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>
<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>");
}
}
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>");
}
}
How to Run?
> Start Apache Server
> Start localhost and open program folder
> type url '/hello'
> Start Apache Server
> Start localhost and open program folder
> type url '/hello'
0 comments :