Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP redirection

 
Nick Verma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have two drop down boxes and depending on the value selected the appropriate jsp page should be loaded. I am wrong somewhere. Please let me know where I am wrong.
<HTML>
<BODY>
<form method = "post" action = "servers.jsp">
<h3>SUPER-1</h3><br/>
<select name="superbapi1">
<option name="server1" value = "temp1" />
<option name="server1" value = "temp2" />
<input type = "submit" value = "Submit" />
</select>
<h3>SUPER-2</h3><br/>
<select name="superbapi2">
<option name="server2" value = "temp1" />
<option name="server2" value = "temp2" />
<input type = "submit" value = "Submit" />
</select>
</form>
<%
String name1 = request.getParameter("server1");
String name2 = request.getParameter("server2");
if(name1="temp1"){
%>
<jsp:forward page = "status_sb1.jsp?server=temp1"%>
<%
}
%>

<%
if(name1="temp2"){
%>
<jsp:forward page = "status_sb1.jsp?server=temp2" %>
<%
}
%>
<%
if(name2="temp1"){
%>
<jsp:forward page = "status_sb2.jsp?server=temp1" %>
<%
}
%>
<%
if(name2="temp2"){
%>
<jsp:forward page = "status_sb2.jsp?server=temp2" %>
<%
}
%>
</BODY>
</HTML>

Thanks for your help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps some insight on what "I am wrong somewhere" means would help?
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to look for the name of the select box, not the name of the option. Your request params are null here...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic