Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using libtags

 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I have a variable in my servlet called "credit" which has a value of 100. I use requestdispatcher to forward to my JSP page. How do I print the value of credit on the JSP page ?
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on the type of the variable "credit" ( i believe its Integer). To be very simple userequest.setAttribute() in servlet and use request.getAttribute() to get the same in jsp.

Note the setAttribute takes Object only so "1000" Stored in String/Integer. But avoid using scriplets in JSP and go for bean class and use EL instead.check this setAttrribute
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value is string. What about using something like:




I havent tested it because Im still writing the code.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup , use like this. Check the syntax.
<cut value="${credit}" />

Also , you use requestScope.credit to get values from specific scope
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic