Ask Experts Questions for FREE Help !
Ask
    hancok's Avatar
    hancok Posts: 1, Reputation: 1
    New Member
     
    #1

    Mar 30, 2010, 05:46 AM
    servlet,html form problem
    Servlet,html form problem?
    Hi,this is hancok.I am getting the error when I click submit button after filling the fileds of the form.
    the eror is as follows.

    This webpage is not found.

    No webpage was found for the web address: file:///C:/formapp/f1?text1=madhu&age=18…

    More information on this error
    Below is the original error message

    Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.


    I have the Form1 class in C:\Tomcat 5.0\webapps\formapp\WEB-INF\classes
    I have the classes folder and web.xml in C:\Tomcat 5.0\webapps\formapp\WEB-INF

    my Form1 class is as follows,

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

    public class Form1 extends HttpServlet{

    public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    String name,add;
    int age;

    name = request.getParameter("text1");
    add = request.getParameter("text3");
    age = Integer.parseInt(request.getParameter("t…

    if(age>=18){

    out.println("<h1>Registration successfully completed");
    out.println("fashion ticket will be dispatched");

    } else{

    out.println("<br> <br>you are not eligible");
    }

    }
    }

    my web.xml is as follows,

    <web-app>

    <servlet>
    <servlet-name>my</servlet-name>
    <servlet-class>Form1</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>my</servlet-name>
    <url-pattern>/f1</url-pattern>
    </servlet-mapping>
    </web-app>

    i have the form1.html file and WEB-INF in C:\Tomcat 5.0\webapps\formapp

    my html file is as follows,

    <html>

    <head><title>Registration Form</title></head>
    <body>

    <h2><br><br><form name="form1" method="get" action="/formapp/f1">

    Enter name:<input type="text" name=" name=" />

    <br>
    Enter age:<input type="text" />

    <br>
    Enter age:<input type="age" name="text" />
    <br>
    Enter address:<input type="address" name="submit" />
    <br>
    <input type="submit" />
    <br>
    </form>
    </body>
    </html>

    when I click on the html file, then I get ,



    Enter name:
    Enter age:
    Enter address:

    but,after entering details in the fields I click the submit button
    but it won't call the servlet(Form1.java) instead the browser shows the error as follows,

    This webpage is not found.

    No webpage was found for the web address: file:///C:/formapp/f1?text1=ma&age=18&ad…

    More information on this error
    Below is the original error message

    Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.
    shaik_hasan's Avatar
    shaik_hasan Posts: 2, Reputation: 1
    New Member
     
    #2

    May 21, 2010, 06:35 PM

    <html>

    <head><title>Registration Form</title></head>
    <body>

    <h2><br><br><form name="form1" method="get" action="./formapp/f1">

    Enter name:<input type="text" name="text1" />

    <br>
    Enter age:<input type="text" name="age" />
    <br>
    Enter address:<input type="text" name="address" />
    <br>
    <input type="submit" value="submit" />
    <br>
    </form>
    </body>
    </html>

    U modify the HTML file as given above. I did nothing except placing a "." which represents current directory. This wil definetely work.

    Or else do another thing

    MOdidy the XML (web.xml) as follows:

    <web-app>

    <servlet>
    <servlet-name>my</servlet-name>
    <servlet-class>Form1</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>my</servlet-name>
    <url-pattern>./f1</url-pattern>
    </servlet-mapping>
    </web-app>


    In this also i placed "." in the URL-PATTERN. Check it out. It definitely work.

    Waiting eagerly for your reply/

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Doubt in Servlet [ 4 Answers ]

Hi Guys.. I got error when I call plain code in servlet.. Kindly look my program BeerExpert.java import java.util.*; public class BeerExpert

Unable to include servlet package [ 1 Answers ]

I have installed apache tomcat 5.5 n also set the classpath but at the time of compiling the servlet prog it is giving error unable to include import javax.servlet.*; n cannot find many symbol like HttpServlet,ServletConfig... So give me some answer on this.

Mistake on W-2 form, serious problem [ 1 Answers ]

My wife and I both worked in New York City for all of 2004. In August of that year, we moved to New Jersey, from New York City. My W-2 accurately reflects the NY state taxes taken out over the entire year, as well as the city taxes taken out during the time we were residents. The huge...


View more questions Search