Link to home
Start Free TrialLog in
Avatar of divvela
divvela

asked on

Forwarding to a new jsp without passing quesry string parameters

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
ASKER CERTIFIED SOLUTION
Avatar of anthony_castillon
anthony_castillon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of anthony_castillon
anthony_castillon

Avatar of divvela

ASKER

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.
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.
Avatar of divvela

ASKER

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
The query string will appear as this

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

if your <form method="get">.  Use "post" instead.
Avatar of divvela

ASKER

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

Srinivas
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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