Hi all, here is a newbie's question:

For example, i have a page called accountList.jsp, which displays an account 
list of a certain customer. Each account has an ID as its primary key. Customer 
may click on the "Close" hyperlink to close an account. The hyperlink is like 
this: 

<a href="closeAccount.do?accountId=100">Close</a>

As you may see, the parameter accountId is passed via the GET method.

In my Struts configuration file, an action element is defined as the following: 
<action    path="/closeAccount"    
type="org.apache.struts.actions.ForwardAction"    parameter="/closeAccount.jsp" 
/>        



When customer clicks on the hyperlink, ActionServlet receives the HTTP request, 
pre-processes it and forwards it to ForwardAction, who will simply forward the 
request to closeAccount.jsp. That page then asks customer to confirm the 
operation ("are you sure that you want to close account No. 100?"). The problem 
is, ActionServlet seems to have modified the request, so in my 
closeAccount.jsp, i cannot retrieve the accountId parameter: 
request.getAttribute("accountId") returns null.

I dumped the contents in the HTTP request that closeAccount.jsp receives. They 
look like this: 
javax.servlet.forward.request_uri = /badba/closeAccount.do 
javax.servlet.forward.context_path = /badba javax.servlet.forward.servlet_path 
= /closeAccount.do javax.servlet.forward.query_string = accountId=100 
org.apache.struts.action.mapping.instance = 
ActionConfig[path=/closeAccount,parameter=/closeAccount.jsp,scope=session,type=org.apache.struts.actions.ForwardAction
 org.apache.struts.action.MODULE = [EMAIL PROTECTED]         



In my web.xml file, i defined a security-constraint element to prevent customer 
from visiting JSP pages directly, so every request must pass through 
ActionServlet, and parameters passed via GET method will always be modified 
before the request arrives to a JSP page. The question is: how to retrieve 
those parameters in my JSP page? Using 
request.getAttribute("javax.servlet.forward.query_string") to get the value 
accountId=100 and then parsing the String seems to be a very stupid method.

Thanks in advance for your help.

Regards.

heavyz



ZHENG Zhong


---------------------------------
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!

Reply via email to