Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

trying to use request.getParameter in jsp

Posted on 2004-03-27
3
Medium Priority
?
298 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 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

877 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