Solved

Forwarding to a new jsp without passing quesry string parameters

Posted on 2003-12-11
12
373 Views
Last Modified: 2010-04-01
All :
Is there any to forward to a new JSP ( lets says Test2.jsp ) without passing Query string parameters from another JSP ( lets says Test1.jsp ).
But the limitation is
1) i should not use response.sendReidrect() method
2) The redirect should not pass the Query string parameters from original request to new JSP

I am trying to use RequestDispatcher.redirect(request,response) , but it is passing the Query string parameters to new JSP.

Thanks in advance for your help.

Srinivas
0
Comment
Question by:divvela
  • 3
  • 3
  • 2
  • +2
12 Comments
 
LVL 2

Accepted Solution

by:
anthony_castillon earned 84 total points
ID: 9923626
Use this:

<jsp:forward  .......>
       <jsp:param name="param1"  value="value1"/>
       <jsp:param name="param2"  value="value2"/>

</jsp:forward>
0
 
LVL 2

Expert Comment

by:anthony_castillon
ID: 9923633
0
 

Author Comment

by:divvela
ID: 9924479
Anthony,
<jsp:forward  .......> is also passing Query string parameters from original request to New JSP. I don't want to pass the query string parameters to new JSP.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9924737
I can't see any documented way around this (though I don't have as much experience with Servlets/JSP as some of the other experts here).

divvela, could you elaborate a bit about why you need to strip the parameters?  Some insight might allow one of us to see a different way of approaching the problem.
0
 

Author Comment

by:divvela
ID: 9925082
jimmack,
I have two JSP's Test1.jsp and Test2.jsp. We will get a request to Test1.jsp with some query string parameters
like this http://server/test1.jsp?par1=1&par2=2....etc
Whenever one of the QueryString parameter(par1,par2 etc....) values are not in the form we expect our JSP will throw ILLEGALARGUMENTEXPECTION . Now what want todo is,
whenever we get the ILLEGALARGUMENTEXPECTION expection because of those query string values we want to redirect it to a Test2.jsp without Querystring values.
I can do it using response.sendRedirect(). But our code somehow does not allow todo this.
So i need a way to redirect it to Test2.jsp from Test1.jsp by stripping off QUery string parameters . Hope i have explained it in a better way. Let me know if you have further more questions .. Thanks you very much for your response.

Srinivas
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:anthony_castillon
ID: 9925190
The query string will appear as this

http://server/test1.jsp?par1=1&par2=2....etc

if your <form method="get">.  Use "post" instead.
0
 

Author Comment

by:divvela
ID: 9925218
anthony,
 The request from a software on the client machine. Its not a website . So i cannot change it to Post method.

Srinivas
0
 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 83 total points
ID: 9925448
I would suggest you to consider what other experts have suggested, especially I can think of any reason why response.sendRedirect cannot be used.
BUT, if you must to this, there is actually a way to do it.
you'll need to define a java class which implements HttpServletRequest interface:

import java.util.*;
import java.servlet.*;
import java.servlet.http.*;

public class MyHttpRequest implements HttpServletRequest {
  HttpServletRequest raw;
  MyHttpRequest( HttpServletRequest rawRequest ) {
    this.raw = rawRequest;
  }
  public String getParameter( String name ) {
    return null;
  }
  public Enumeration getParameterNames( ) {
    return Collections.enumeration( Collections.EMPTY_LIST );
  }
  public Map getParameterMap() {
    return Collections.EMPTY_MAP;
  }
  public Type allOtherMethodsInInterface( parameter list ) {
    [return] raw.allOtherMethodsInInterface( parameter list );
  }
  ......
}

then you can do:
RequestDispatcher.redirect( new MyHttpRequst(request), response)

let me know if you have futher enquires.
0
 
LVL 6

Assisted Solution

by:jarasa
jarasa earned 83 total points
ID: 10001477
If you just want to call another JSP without any params just do it with JavaScript:

.......
<SCRIPT>
function forward(){
top.location.href="test2.jsp"
}
</SCRIPT>
......
<input type=button OnClick="javascript:forward();">
.....
or directly:
.....
<input type=button OnClick="javascript:top.location.href='test2.jsp';">
.....
Javier
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10001488
If you don't want the Client to interact with your JSP you can also do this
Test1.jsp
..........
Your JSP CODE
.......
<HTML>
<HEAD>
</HEAD>
<BODY>

<P> Please Wait..... </P>

<SCRIPT>
top.location.href="test2.jsp"
</SCRIPT>
</BODY>
</HTML>

This will call Test2.jsp without any parameters and and without client inteeact.

But as Kennethxu says I don't know why you don't want to make a response.sendRedirect....

Javier
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In the hope of saving someone else's sanity... About a year ago we bought a Cisco 1921 router with two ADSL/VDSL EHWIC cards to load balance local network traffic over the two broadband lines we have, but we couldn't get the routing to work consi…
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

24 Experts available now in Live!

Get 1:1 Help Now