relativley simple jsp problem


Web tier: servlets, JSP, Web frameworks: relativley simple jsp problem

  1. relativley simple jsp problem (1 messages)

    I'm working in a small project and part of it is when a user registers,
    there details are checked for errors (eg null value). If there is an error
    it should appear on screen if there is not it should forward to
    a confirmation page from the register page. A simple example of the code
    on both pages appears below. At the moment it is not working. I would appreciate
    any help

    JSP #1: exampleregister.jsp

    form name="form1" method="post" action="/exampleregister.jsp">
        <input type="text" name="username">
        <input type="text" name="age">
        <input type="submit" name="submit" value="submit">
    <%if (request.getParameter("submit") == null) { %>
    <% if (request.getParameter("username") == null) {%>
    <br>must show user name
    <% if (request.getParameter("age") == null) {%>
    <br> must show age
    <jsp:forward page="/exampleconfirm.jsp" />
    <% } %>
    <% } %>
    <% } %>

    JSP #2: exampleconfirm.jsp

    <body bgcolor="#FFFFFF" text="#000000">
    Details entered =
    <form name="form1" method="post" action="">
        <input type="text" name="username" value="<%=request.getParameter("username")%>">
        <input type="text" name="age" value="<%=request.getParameter("age")%>">
        <input type="submit" name="Submit" value="Submit">

    Anybody any ideas where I'm going wrong??
  2. relativley simple jsp problem[ Go to top ]

    This is what is wrong....

    <%if (request.getParameter("submit") == null) {

    when the form is submitted... the param submit is not null... so the if construct is skipped