Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Multiple displays

Posted on 2004-11-08
8
Medium Priority
?
212 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:mmartha
  • 5
  • 3
8 Comments
 
LVL 2

Expert Comment

by:arnon81
ID: 12526484
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
 
LVL 2

Accepted Solution

by:
arnon81 earned 2000 total points
ID: 12526526
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
 
LVL 2

Author Comment

by:mmartha
ID: 12527654
i want it in only one page, please. I don't want to redirect to other pages.

thanks =)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:arnon81
ID: 12528082
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
 
LVL 2

Expert Comment

by:arnon81
ID: 12528098
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
 
LVL 2

Expert Comment

by:arnon81
ID: 12528275
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
 
LVL 2

Author Comment

by:mmartha
ID: 12528903
The last answer wasn't what I needed but it worked.


thank youuuuuuuuuuuuu :P

MMarts :)
0
 
LVL 2

Author Comment

by:mmartha
ID: 12528908
sorry, it was what I needed, it wasn't what I wanted.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What happened when I tried to make my phone, a Samsung Galaxy S8, stop dropping all WiFi signals was a saga I won't repeat here, but what you might want to know is how it started and how I got it working again.
Ready to kick start your career in 2018? Add app developer skills to your resume. January’s Course of the Month features Android App Development training with hands-on learning.  Read on to learn why these skills are important.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question