hi all,
this one is simple program, i'm just using servlets and a html file. Getting fields from html file and displaying it on browser but it's not showing on browser, plz tell me what i've done wrong..
i'm using textpad with apache-tomcat, have done it on Netbeans but it's not working on textpad.
Display.java
pg.htmlCode:import java.io.*; import javax.servlet.http.*; import javax.servlet.*; public class Display extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String firstName = request.getParameter("firstName"); String surname = request.getParameter("surname"); out.println("<html><head><title>Servlet GreetingServlet</title></head><body>"); out.println("<h1>Servlet GreetingServlet at " + request.getContextPath () + "</h1>"); out.println("<p>Welcome " + firstName + " " + surname + "</p>"); out.println("</body>"); out.println("</html>"); out.close(); } }
thanks..Code:<html> <head> <title>Insert title here</title> </head> <body> <form action="Display" method="GET"> First Name: <input type="text" name="firstName" size="20"><br> Surname: <input type="text" name="surname" size="20"> <br><br> <input type="submit" value="Submit"> </form> </body> </html>





Reply With Quote