Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Forwarding to a new jsp without passing quesry string parameters

Posted on 2003-12-11
12
Medium Priority
?
383 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
[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
  • 3
  • 3
  • 2
  • +2
12 Comments
 
LVL 2

Accepted Solution

by:
anthony_castillon earned 336 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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 332 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 332 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

598 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