Multiple displays

Hi, I am programming a JSP web page:

*In the registration form I have the next:

<P><FONT size="+1"><B>User Type</B></FONT></P>
<FORM><SELECT name="UType">
      <OPTION value="Provider">Chamberlain Provider</OPTION>
      <OPTION value="Intern">Chamberlain User</OPTION>
</SELECT></FORM>

*When in the Utype is selected Provider I need to display:

<FORM>
<TABLE border="0">
      <TBODY>
            <TR>
                  <TD width="167">Complete Name</TD>
                  <TD width="337"><INPUT type="text" name="PName" size="20"></TD>
            </TR>
            <TR>
                  <TD width="167">Gender</TD>
                  <TD width="337"><INPUT type="radio" name="PGender">Male
                  <INPUT type="radio" name="PGender">Female</TD>
            </TR>
            <TR>
                  <TD width="167">Birth date</TD>
                  <TD width="337"><LABEL for="Month"><SELECT class="PPRField"
                        id="Month" tabindex="481" name="PMonth">
                        <OPTION value="DGHJLNS" selected>Month</OPTION>
                        <OPTION value="1">January</OPTION>
                        <OPTION value="2">February</OPTION>
                        <OPTION value="3">March</OPTION>
                        <OPTION value="4">April</OPTION>
                        <OPTION value="5">May</OPTION>
                        <OPTION value="12">December</OPTION>
                  </SELECT></LABEL><LABEL for="Day"><SELECT class="PPRField" id="Day"
                        tabindex="511" name="PDay">
                        <OPTION value="DGHJLNS" selected>Day</OPTION>
                        <OPTION value="1">1</OPTION>
                        <OPTION value="2">2</OPTION>
                        <OPTION value="29">29</OPTION>
                        <OPTION value="30">30</OPTION>
                        <OPTION value="31">31</OPTION>
                  </SELECT></LABEL><INPUT class="PPRField" tabindex="541" maxlength="4"
                        size="5" name="PYear" autocomplete="OFF">&nbsp;<SPAN
                        class="PPSubDesTxt">(ex. 1999)</SPAN></TD>
            </TR>
            <TR>
                  <TD width="167">Job title</TD>
                  <TD width="337"><INPUT type="text" name="PJob" size="20"></TD>
            </TR>
            <TR>
                  <TD width="167">E-mail</TD>
                  <TD width="337"><INPUT type="text" name="PMail" size="20"></TD>
            </TR>
      </TBODY>
</TABLE>
</FORM>

*When in the Utype is selected User I need to display:

<FORM>
<FONT size="+1"><B>Personal Information</B></FONT></P>
<TABLE border="0">
      <TBODY>
            <TR>
                  <TD width="166">Complete Name</TD>
                  <TD width="344"><INPUT type="text" name="IName" size="20"></TD>
            </TR>
            <TR>
                  <TD width="166">Username</TD>
                  <TD width="344"><INPUT type="text" name="IUsername" size="20" maxlength="10"></TD>
            </TR>
            <TR>
                  <TD width="166">E-mail</TD>
                  <TD width="344"><INPUT type="text" name="IUsernameM" size="20">@grupochamberlain.com</TD>
            </TR>
            <TR>
                  <TD width="166">Department</TD>
                  <TD width="344"><SELECT name="IDepartment">
                        <OPTION value="IQuality">Quality</OPTION>
                        <OPTION value="IManufacture">Manufacture</OPTION>
                  </SELECT></TD>
            </TR>
            <TR>
                  <TD width="166">Job title</TD>
                  <TD width="344"><INPUT type="text" name="IJob" size="20"></TD>
            </TR>
      </TBODY>
</FORM>

how can I do this in JSP?
LVL 2
mmarthaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnon81Commented:
mmartha
here's some code that can get you started
<1.jsp>
<%@ page language=java %>


<P><FONT size="+1"><B>User Type</B></FONT></P>
<FORM method=post action="2.jsp">
<SELECT name="UType" >
     <OPTION value="Provider">Chamberlain Provider</OPTION>
     <OPTION value="Intern">Chamberlain User</OPTION>
</SELECT>
<input type=submit value=Submit>
</FORM>




<2.jsp>
<%@ page language=java %>

<FORM method=post action="3.jsp">
<input type=hidden value='<%=request.getParameter("UType")%>' name='UType'/>
<TABLE border="0">
     <TBODY>
          <TR>
               <TD width="167">Complete Name</TD>
               <TD width="337"><INPUT type="text" name="PName" size="20"></TD>
          </TR>
          <TR>
               <TD width="167">Gender</TD>
               <TD width="337"><INPUT type="radio" name="PGender" value="m">Male
               <INPUT type="radio" name="PGender" value="f">Female</TD>
          </TR>
          <TR>
               <TD width="167">Birth date</TD>
               <TD width="337"><LABEL for="Month"><SELECT class="PPRField"
                    id="Month" tabindex="481" name="PMonth">
                    <OPTION value="DGHJLNS" selected>Month</OPTION>
                    <OPTION value="1">January</OPTION>
                    <OPTION value="2">February</OPTION>
                    <OPTION value="3">March</OPTION>
                    <OPTION value="4">April</OPTION>
                    <OPTION value="5">May</OPTION>
                    <OPTION value="12">December</OPTION>
               </SELECT></LABEL><LABEL for="Day"><SELECT class="PPRField" id="Day"
                    tabindex="511" name="PDay">
                    <OPTION value="DGHJLNS" selected>Day</OPTION>
                    <OPTION value="1">1</OPTION>
                    <OPTION value="2">2</OPTION>
                    <OPTION value="29">29</OPTION>
                    <OPTION value="30">30</OPTION>
                    <OPTION value="31">31</OPTION>
               </SELECT></LABEL><INPUT class="PPRField" tabindex="541" maxlength="4"
                    size="5" name="PYear" autocomplete="OFF">&nbsp;<SPAN
                    class="PPSubDesTxt">(ex. 1999)</SPAN></TD>
          </TR>
          <TR>
               <TD width="167">Job title</TD>
               <TD width="337"><INPUT type="text" name="PJob" size="20"></TD>
          </TR>
          <TR>
               <TD width="167">E-mail</TD>
               <TD width="337"><INPUT type="text" name="PMail" size="20"></TD>
          </TR>
     </TBODY>
</TABLE>
<input type=submit value=submit/>
</FORM>


<3.jsp>
<%@ page language=java %>
<%!
public String decodeMonth(String t)
{
if (t.equals("1"))
 return "January";
else if (t.equals("2"))
return "February";


else if (t.equals("3"))
 return "March";
else if (t.equals("4"))
 return "April";
else if (t.equals("5"))
return "May";
else if (t.equals("12"))
 return "December";
else
      return "";
}
%>
<%



String PMonth="";
if (request.getParameter("PMonth")!=null)
{
      PMonth=decodeMonth(request.getParameter("PMonth"));
      
}
%>
<FONT size="+1"><B>Personal Information</B></FONT></P>
<TABLE border="0">
     <TBODY>
          <TR>
               <TD width="166">Complete Name</TD>
               <TD width="344"><INPUT type="text" name="IName" size="20" value='<%=request.getParameter("PName")%>'></TD>
          </TR>
          <TR>
               <TD width="166">Username</TD>
               <TD width="344"><INPUT type="text" name="IUsername" size="20" maxlength="10"></TD>
          </TR>
          <TR>
               <TD width="166">E-mail</TD>
               <TD width="344"><INPUT type="text" name="IUsernameM" value='<%=request.getParameter("PMail")%>' size="20">@grupochamberlain.com</TD>
          </TR>
          <TR>
               <TD width="166">Department</TD>
               <TD width="344"><SELECT name="IDepartment">
                    <OPTION value="IQuality">Quality</option>
                    <OPTION value="IManufacture">Manufacture</option>
               </SELECT></TD>
          </TR>
          <TR>
               <TD width="166">Job title</TD>
               <TD width="344"><INPUT type="text" name="IJob" size="20" value='<%=request.getParameter("PJob")%>'></TD>
          </TR>
     </TBODY>

0
arnon81Commented:
oops sorry there was some typo in my previous post,
here's the correct one.

<1.jsp>

<%@ page language=java %>


<P><FONT size="+1"><B>User Type</B></FONT></P>
<FORM method=post action="2.jsp">
<SELECT name="UType" >
     <OPTION value="Provider">Chamberlain Provider</OPTION>
     <OPTION value="Intern">Chamberlain User</OPTION>
</SELECT>
<input type=submit value=Submit>
</FORM>


<2.jsp>
<%@ page language=java %>


<%
if (request.getParameter("UType").equals("Intern"))
      response.sendRedirect ("3.jsp");

%>

<FORM method=post action="3.jsp">
<input type=hidden value='<%=request.getParameter("UType")%>' name='UType'/>
<TABLE border="0">
     <TBODY>
          <TR>
               <TD width="167">Complete Name</TD>
               <TD width="337"><INPUT type="text" name="PName" size="20"></TD>
          </TR>
          <TR>
               <TD width="167">Gender</TD>
               <TD width="337"><INPUT type="radio" name="PGender" value="m">Male
               <INPUT type="radio" name="PGender" value="f">Female</TD>
          </TR>
          <TR>
               <TD width="167">Birth date</TD>
               <TD width="337"><LABEL for="Month"><SELECT class="PPRField"
                    id="Month" tabindex="481" name="PMonth">
                    <OPTION value="DGHJLNS" selected>Month</OPTION>
                    <OPTION value="1">January</OPTION>
                    <OPTION value="2">February</OPTION>
                    <OPTION value="3">March</OPTION>
                    <OPTION value="4">April</OPTION>
                    <OPTION value="5">May</OPTION>
                    <OPTION value="12">December</OPTION>
               </SELECT></LABEL><LABEL for="Day"><SELECT class="PPRField" id="Day"
                    tabindex="511" name="PDay">
                    <OPTION value="DGHJLNS" selected>Day</OPTION>
                    <OPTION value="1">1</OPTION>
                    <OPTION value="2">2</OPTION>
                    <OPTION value="29">29</OPTION>
                    <OPTION value="30">30</OPTION>
                    <OPTION value="31">31</OPTION>
               </SELECT></LABEL><INPUT class="PPRField" tabindex="541" maxlength="4"
                    size="5" name="PYear" autocomplete="OFF">&nbsp;<SPAN
                    class="PPSubDesTxt">(ex. 1999)</SPAN></TD>
          </TR>
          <TR>
               <TD width="167">Job title</TD>
               <TD width="337"><INPUT type="text" name="PJob" size="20"></TD>
          </TR>
          <TR>
               <TD width="167">E-mail</TD>
               <TD width="337"><INPUT type="text" name="PMail" size="20"></TD>
          </TR>
     </TBODY>
</TABLE>
<input type=submit value=submit/>
</FORM>


<3.jsp>
<%@ page language=java %>
<%!
public String decodeMonth(String t)
{
if (t.equals("1"))
 return "January";
else if (t.equals("2"))
return "February";


else if (t.equals("3"))
 return "March";
else if (t.equals("4"))
 return "April";
else if (t.equals("5"))
return "May";
else if (t.equals("12"))
 return "December";
else
      return "";
}
%>
<%



String PMonth="";
if (request.getParameter("PMonth")!=null)
{
      PMonth=decodeMonth(request.getParameter("PMonth"));
      
}
%>
<FONT size="+1"><B>Personal Information</B></FONT></P>
<TABLE border="0">
     <TBODY>
          <TR>
               <TD width="166">Complete Name</TD>
               <TD width="344"><INPUT type="text" name="IName" size="20" ></TD>
          </TR>
          <TR>
               <TD width="166">Username</TD>
               <TD width="344"><INPUT type="text" name="IUsername" size="20" maxlength="10"></TD>
          </TR>
          <TR>
               <TD width="166">E-mail</TD>
               <TD width="344"><INPUT type="text" name="IUsernameM"  size="20">@grupochamberlain.com</TD>
          </TR>
          <TR>
               <TD width="166">Department</TD>
               <TD width="344"><SELECT name="IDepartment">
                    <OPTION value="IQuality">Quality</option>
                    <OPTION value="IManufacture">Manufacture</option>
               </SELECT></TD>
          </TR>
          <TR>
               <TD width="166">Job title</TD>
               <TD width="344"><INPUT type="text" name="IJob" size="20" ></TD>
          </TR>
     </TBODY>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mmarthaAuthor Commented:
i want it in only one page, please. I don't want to redirect to other pages.

thanks =)
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

arnon81Commented:
Hi mmartha
allright, try this one:


<%@ page language=java %>


<%
if (request.getParameter("1")!=null)
{
      
      if (request.getParameter("UType").equals("Provider"))
      {
            //display 2
            %>
            <FORM method=post action="3.jsp">
            <input type=hidden value='<%=request.getParameter("UType")%>' name='UType'/>
            <TABLE border="0">
                   <TBODY>
                          <TR>
                                 <TD width="167">Complete Name</TD>
                                 <TD width="337"><INPUT type="text" name="PName" size="20"></TD>
                          </TR>
                          <TR>
                                 <TD width="167">Gender</TD>
                                 <TD width="337"><INPUT type="radio" name="PGender" value="m">Male
                                 <INPUT type="radio" name="PGender" value="f">Female</TD>
                          </TR>
                          <TR>
                                 <TD width="167">Birth date</TD>
                                 <TD width="337"><LABEL for="Month"><SELECT class="PPRField"
                                          id="Month" tabindex="481" name="PMonth">
                                          <OPTION value="DGHJLNS" selected>Month</OPTION>
                                          <OPTION value="1">January</OPTION>
                                          <OPTION value="2">February</OPTION>
                                          <OPTION value="3">March</OPTION>
                                          <OPTION value="4">April</OPTION>
                                          <OPTION value="5">May</OPTION>
                                          <OPTION value="12">December</OPTION>
                                 </SELECT></LABEL><LABEL for="Day"><SELECT class="PPRField" id="Day"
                                          tabindex="511" name="PDay">
                                          <OPTION value="DGHJLNS" selected>Day</OPTION>
                                          <OPTION value="1">1</OPTION>
                                          <OPTION value="2">2</OPTION>
                                          <OPTION value="29">29</OPTION>
                                          <OPTION value="30">30</OPTION>
                                          <OPTION value="31">31</OPTION>
                                 </SELECT></LABEL><INPUT class="PPRField" tabindex="541" maxlength="4"
                                          size="5" name="PYear" autocomplete="OFF">&nbsp;<SPAN
                                          class="PPSubDesTxt">(ex. 1999)</SPAN></TD>
                          </TR>
                          <TR>
                                 <TD width="167">Job title</TD>
                                 <TD width="337"><INPUT type="text" name="PJob" size="20"></TD>
                          </TR>
                          <TR>
                                 <TD width="167">E-mail</TD>
                                 <TD width="337"><INPUT type="text" name="PMail" size="20"></TD>
                          </TR>
                   </TBODY>
            </TABLE>
            <input type=submit value=submit/>
            </FORM>
            <%
      }
      else
      {//display 3
            %>
            
            <FONT size="+1"><B>Personal Information</B></FONT></P>
            <TABLE border="0">
                   <TBODY>
                          <TR>
                                 <TD width="166">Complete Name</TD>
                                 <TD width="344"><INPUT type="text" name="IName" size="20" ></TD>
                          </TR>
                          <TR>
                                 <TD width="166">Username</TD>
                                 <TD width="344"><INPUT type="text" name="IUsername" size="20" maxlength="10"></TD>
                          </TR>
                          <TR>
                                 <TD width="166">E-mail</TD>
                                 <TD width="344"><INPUT type="text" name="IUsernameM"  size="20">@grupochamberlain.com</TD>
                          </TR>
                          <TR>
                                 <TD width="166">Department</TD>
                                 <TD width="344"><SELECT name="IDepartment">
                                          <OPTION value="IQuality">Quality</option>
                                          <OPTION value="IManufacture">Manufacture</option>
                                 </SELECT></TD>
                          </TR>
                          <TR>
                                 <TD width="166">Job title</TD>
                                 <TD width="344"><INPUT type="text" name="IJob" size="20" ></TD>
                          </TR>
                   </TBODY>
                   <%

      }
}
%>




<P><FONT size="+1"><B>User Type</B></FONT></P>
<FORM method=post action="2.jsp">
<SELECT name="UType" >
     <OPTION value="Provider">Chamberlain Provider</OPTION>
     <OPTION value="Intern">Chamberlain User</OPTION>
</SELECT>
<input type=hidden value="1" name="1"/>
<input type=submit value=Submit>
</FORM>

Sincerely,
Arnon
0
arnon81Commented:
Sorry, another typo...
Here's the correct one


<1.jsp>

<%@ page language=java %>


<%
if (request.getParameter("1")!=null)
{
      
      if (request.getParameter("UType").equals("Provider"))
      {
            //display 2
            %>
            <FORM>
            <input type=hidden value='<%=request.getParameter("UType")%>' name='UType'/>
            <TABLE border="0">
                   <TBODY>
                          <TR>
                                 <TD width="167">Complete Name</TD>
                                 <TD width="337"><INPUT type="text" name="PName" size="20"></TD>
                          </TR>
                          <TR>
                                 <TD width="167">Gender</TD>
                                 <TD width="337"><INPUT type="radio" name="PGender" value="m">Male
                                 <INPUT type="radio" name="PGender" value="f">Female</TD>
                          </TR>
                          <TR>
                                 <TD width="167">Birth date</TD>
                                 <TD width="337"><LABEL for="Month"><SELECT class="PPRField"
                                          id="Month" tabindex="481" name="PMonth">
                                          <OPTION value="DGHJLNS" selected>Month</OPTION>
                                          <OPTION value="1">January</OPTION>
                                          <OPTION value="2">February</OPTION>
                                          <OPTION value="3">March</OPTION>
                                          <OPTION value="4">April</OPTION>
                                          <OPTION value="5">May</OPTION>
                                          <OPTION value="12">December</OPTION>
                                 </SELECT></LABEL><LABEL for="Day"><SELECT class="PPRField" id="Day"
                                          tabindex="511" name="PDay">
                                          <OPTION value="DGHJLNS" selected>Day</OPTION>
                                          <OPTION value="1">1</OPTION>
                                          <OPTION value="2">2</OPTION>
                                          <OPTION value="29">29</OPTION>
                                          <OPTION value="30">30</OPTION>
                                          <OPTION value="31">31</OPTION>
                                 </SELECT></LABEL><INPUT class="PPRField" tabindex="541" maxlength="4"
                                          size="5" name="PYear" autocomplete="OFF">&nbsp;<SPAN
                                          class="PPSubDesTxt">(ex. 1999)</SPAN></TD>
                          </TR>
                          <TR>
                                 <TD width="167">Job title</TD>
                                 <TD width="337"><INPUT type="text" name="PJob" size="20"></TD>
                          </TR>
                          <TR>
                                 <TD width="167">E-mail</TD>
                                 <TD width="337"><INPUT type="text" name="PMail" size="20"></TD>
                          </TR>
                   </TBODY>
            </TABLE>
            <input type=submit value=submit/>
            </FORM>
            <%
      }
      else
      {//display 3
            %>
            
            <FONT size="+1"><B>Personal Information</B></FONT></P>
            <TABLE border="0">
                   <TBODY>
                          <TR>
                                 <TD width="166">Complete Name</TD>
                                 <TD width="344"><INPUT type="text" name="IName" size="20" ></TD>
                          </TR>
                          <TR>
                                 <TD width="166">Username</TD>
                                 <TD width="344"><INPUT type="text" name="IUsername" size="20" maxlength="10"></TD>
                          </TR>
                          <TR>
                                 <TD width="166">E-mail</TD>
                                 <TD width="344"><INPUT type="text" name="IUsernameM"  size="20">@grupochamberlain.com</TD>
                          </TR>
                          <TR>
                                 <TD width="166">Department</TD>
                                 <TD width="344"><SELECT name="IDepartment">
                                          <OPTION value="IQuality">Quality</option>
                                          <OPTION value="IManufacture">Manufacture</option>
                                 </SELECT></TD>
                          </TR>
                          <TR>
                                 <TD width="166">Job title</TD>
                                 <TD width="344"><INPUT type="text" name="IJob" size="20" ></TD>
                          </TR>
                   </TBODY>
                   <%

      }
}

else
{
%>




<P><FONT size="+1"><B>User Type</B></FONT></P>
<FORM method=post action="1.jsp">
<SELECT name="UType" >
     <OPTION value="Provider">Chamberlain Provider</OPTION>
     <OPTION value="Intern">Chamberlain User</OPTION>
</SELECT>
<input type=hidden value="1" name="1"/>
<input type=submit value=Submit>
</FORM>
<%
}
%>


Sincerely,
Arnon
0
arnon81Commented:
mmartha,
I'd like to make a suggestion, it's just my personal opinion that having multiple forms on 1 jsp page is a bad practice, because it makes it more complex. I have bad personal experience having multiple stuffs on one jsp page, it gives me headache when later on my supervisor wants me to add stuffs/functionality into that page. I would break that form down into 3 jsp pages, so in the long run, it will be easier to manage them. Again, this is just my personal opinion.
0
mmarthaAuthor Commented:
The last answer wasn't what I needed but it worked.


thank youuuuuuuuuuuuu :P

MMarts :)
0
mmarthaAuthor Commented:
sorry, it was what I needed, it wasn't what I wanted.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.