Link to home
Start Free TrialLog in
Avatar of Barbara69
Barbara69Flag for United States of America

asked on

trying to use request.getParameter in jsp

I have a submit button on a error.jsp page. I'm trying to use the error.jsp for more the one possible error message display pages (have 3 servelts in the project). What I want to do is based on the strPage from a servlet either send to registerNewProjects.jsp if it = RegisterNewProjects or the index.jsp if it doesn't (which it won't coming from the other 2 jsps). This particular possible error message display is based on inputted data from the user.  I'm having problems getting the strPage (which is set RegisterNewProjects) to  from the servlet.

i'm using the below to call my script
<FORM name="myform" onSubmit="return page();">
           

<SCRIPT language="JavaScript">
function page()
{  
    if (request.getParameter("strPage")=="RegisterNewProjects")
       {document.myform.action ="registerNewProjects.jsp";}
   else    
       {document.myform.action ="index.jsp";}
        return;
 }                  
</SCRIPT>
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Barbara69

ASKER

Thank you. I had to modify it a little but it works. Here's what I did

<SCRIPT language="JavaScript">
function page()
{
<%
    if ("RegisterNewProjects".equals(getServletContext().getAttribute("Page")))
    {
 %>            
      
      document.myform.action ="/BMAP/jsps/registerNewProjects.jsp";
<%
    }
    else    
    {
%>
       document.myform.action ="/BMAP/jsps/index.jsp";
<%
    }
%>
     
 }              
</SCRIPT>
Good to hear u got it working :)

http://www.objects.com.au/staff/mick