Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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

 
Marshal
Posts: 67415
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67415
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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!
 
Rancher
Posts: 377
Android Spring Java
  • 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~
 
Pay attention! Tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic