Solved

trying to use request.getParameter in jsp

Posted on 2004-03-27
3
292 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
[X]
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
  • 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery - parsing the results returned from webmethod 1 124
maven project in eclipse 11 60
excpetion with multiple catch 11 134
Java Script nested call 3 89
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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