Results 1 to 2 of 2

Thread: [RESOLVED] Servlets

  1. #1
    Hyperactive Member Aash's Avatar
    Join Date
    Dec 09
    Location
    Earth
    Posts
    491

    Resolved [RESOLVED] Servlets

    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
    Code:
    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(); 
    
    }
    
    }
    pg.html
    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>
    thanks..

  2. #2
    Hyperactive Member Aash's Avatar
    Join Date
    Dec 09
    Location
    Earth
    Posts
    491

    Re: Servlets

    it's running now, there was problem in my windows...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •