| Author |
how to use the servlet to get the value from JSTL c:set?
|
Ivy chen
Greenhorn
Joined: Aug 31, 2010
Posts: 16
|
|
I want to use "doUpdate_userInfor_servlet" to get the value "${userInfor}" from JSTL <c:set>
UpData_userInfor.jsp
thanks!
UpData_userInfor.jsp
user_formBean
doUpdate_userInfor_servlet
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
Your question makes no sense as stated. What is the relationship between the JSP and the servlet? Why are you just using normal request parameters? Why would a servlet need info from the JSP that isn't submitted as part of a form?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Ivy chen
Greenhorn
Joined: Aug 31, 2010
Posts: 16
|
|
Bear Bibeault wrote:Your question makes no sense as stated. What is the relationship between the JSP and the servlet? Why are you just using normal request parameters? Why would a servlet need info from the JSP that isn't submitted as part of a form?
got it~thanks~I'm new to JSTL.
I feel quite confuse about the function of<c:set target>.it set the property of a javabean.
Can I get the value from the Bean?
if(yes){
how to ? that I can pass the value as a parameter to a filter or to some other codes?
}
if(no){
Is it the only way that I just can use the <c: out> to get or output the value of the property in other JSPs when I had set the "scope" in the taglib"<jsp:useBean>"?
}
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
Again, I'm confused. A JSP is the end target of a request. Anything done in the JSP should be for the sole purpose of rendering the display. So saying things like "passing the value of <c:set> to a filter" doesn't make a whole lot of sense. What is it that you are really trying to do?
|
 |
Ivy chen
Greenhorn
Joined: Aug 31, 2010
Posts: 16
|
|
Bear Bibeault wrote:Again, I'm confused. A JSP is the end target of a request. Anything done in the JSP should be for the sole purpose of rendering the display. So saying things like "passing the value of <c:set> to a filter" doesn't make a whole lot of sense. What is it that you are really trying to do?
thank u~
I'm doing the exercise of update the sql.
at the begining, I though I can set a property in a JavaBean by the <c: set>,then I can use a sevlet or a filter to get this property.
I'm wrong.
I still have a question:In my project ,a user can update his individual Information in jsp(A), first user fill in his userName (e.g ABC) , servlet(A) get this userName and check wether this userName is in the dateBase , if yes,dispatcher to JSP(B) to let user input his information(PS: userName will be displayed in JSP(B) ),after he finish filling in his information,parameters wil be sent as a part of form to servlet(B).In servlet (B) userName(ABC) is still needed as a parameter to update dateBase.
How can i get the userName in servlet(B)? should I set userName as an attribute in session at the begining or I should user the taglib<jsp: setAttribut> to set the userName in JSP(B) , then sent it to the servlet(B)?
thank you very much!
|
 |
Sean Clark
Rancher
Joined: Jul 15, 2009
Posts: 377
|
|
Hey,
I think you just want to save the username in the session, I'm not sure you can use <jsp: setAttribut> to pass the username to servlet(B).
The only other option I can see would be to send the username as part of JSP(B)'s form as a hidden input and read it again in servlet(B), though I personally wouldn't do this as this value could be tampered with by the client.
Your choice though.
Sean
|
I love this place!
|
 |
Ivy chen
Greenhorn
Joined: Aug 31, 2010
Posts: 16
|
|
Sean Clark wrote:Hey,
I think you just want to save the username in the session, I'm not sure you can use <jsp: setAttribut> to pass the username to servlet(B).
The only other option I can see would be to send the username as part of JSP(B)'s form as a hidden input and read it again in servlet(B), though I personally wouldn't do this as this value could be tampered with by the client.
Your choice though.
Sean
thank you Sean Clark!
Would you please show me the right way?
UpdateDB.jsp(choose which user should be updated)
UpData_userInfor.jsp (that's the JSP(B))
doUpdate_userInfor_servlet (that's the sevlet(B))
thanks a lot~
|
 |
 |
|
|
subject: how to use the servlet to get the value from JSTL c:set?
|
|
|