Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use the servlet to get the value from JSTL c:set?

 
Ivy chen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64975
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ivy chen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64975
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ivy chen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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~
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic