wood burning stoves 2.0*
The moose likes Struts and the fly likes Removing HttpServletRequest parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Removing HttpServletRequest parameters" Watch "Removing HttpServletRequest parameters" New topic
Author

Removing HttpServletRequest parameters

Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
How can I remove the request parameters?

I have this situation:
1- The login page collect the userName and password.
2- The login page send the info. to LoginAction.
3- if authinticated, the LoginAction forward to ResourceAction
4- ResourceAction does some business logic, and forward to resroucePage.
5- ResourcePage uses DisplayTag to display the resources, and adds export links in the buttom.

When I looked at at the source of the html generated by ResourcePage, I was surprised to find out that the links generated by the displayTag adds the userName and password to the links.

Here is a link:
<a href="/MyApp/resources.do?password=password&action=preSelect&action=login&action=select&loginName=
admin&6578706f7274=1&d-49653-e=1"><span class="export csv">CSV </span></a>

The request is not cleared after it is being forward from one action to another. I don't want the loginName nor the password to hang in the request.

How can I remove them?

Thanks


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60765
    
  65

You can't. But you really don't need to.

Firstly, use a POST rather than a GET and the params will not appear on the URL.

Secondly, you should become familiar with the PRG (Post-Redirect-Get) pattern. This article might be helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
Originally posted by Bear Bibeault:
You can't. But you really don't need to.

Firstly, use a POST rather than a GET and the params will not appear on the URL.

Secondly, you should become familiar with the PRG (Post-Redirect-Get) pattern. This article might be helpful.


I am already using 'post' method in my form. I don't know how PRG is related to my problem. I am using Struts for forwards.
rahul khanna
Ranch Hand

Joined: Sep 14, 2005
Posts: 48
If you are using 'Post' it should not happen .. can you paste your code here. it would help to narrow it down
Sunny Gibbony
Ranch Hand

Joined: May 14, 2008
Posts: 39
You can paste your code in http://pastebin.com/ where it can be modified by us.
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
Here is my login form:

<html:form action="/login" method="POST" >
<html:hidden name="loginForm" property="action" value="login" />

<b> Login Name:</b>
<html:text name="loginForm" property="loginName" maxlength="20" size="20" />
<br>
<br>
<b>Password:</b>
<html assword name="loginForm" property="password" maxlength="20" size="20" />
<br>
<br>
<html:submit value="Login" />
</html:form>

In the following page (also is POST), displayTag append the loginName and password to the request parameters list this:

<a href="/MyApp/resources.do?password=password&action=preSelect&action=login&action=select&loginName=
admin&6578706f7274=1&d-49653-e=1"><span class="export csv">CSV </span></a>
[ May 16, 2008: Message edited by: Hanna Habashy ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Removing HttpServletRequest parameters
 
Similar Threads
Can you read this?
Actions in Servlets
Issues Implementing the displayTag
action mapping problem
Need an attribute to be available in different places (SOLVED)