Solved

trying to use request.getParameter in jsp

Posted on 2004-03-27
3
287 Views
Last Modified: 2012-05-04
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>
0
Comment
Question by:Barbara69
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
jsp is executed on the server, whereas your jsp is executed on the client.
Try:

<SCRIPT language="JavaScript">
function page()
{
<%
    if ("RegisterNewProjects".equals(request.getParameter("strPage"))
    {
%>
      document.myform.action ="registerNewProjects.jsp";
<%
    {
    else    
    {
%>
       document.myform.action ="index.jsp";
<%
    }
%>
       return;
 }              
</SCRIPT>
0
 

Author Comment

by:Barbara69
Comment Utility
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>
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Good to hear u got it working :)

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Run jasper report from servlet 1 206
stateless EJB with glassfish 2 68
constructor overloading 2 73
own marker interface 1 43
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now