Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

trying to use request.getParameter in jsp

Posted on 2004-03-27
3
291 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
ID: 10696139
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
ID: 10697384
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
ID: 10697487
Good to hear u got it working :)

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reflections, dynamic class loading 3 75
gZip compression filter 2 174
caughtSpeeding java challenge 16 139
Can't access image with tomcat/html 6 102
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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