• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query on Custom Tags

 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
how can we use Custom Tags to set value for JSP variables?

Thanks and Regards
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not like that.
I want to know how to set JSP variables using Classic Tags or Simple Tags
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just use pageContext.getRequest().setAttribute("name","value"); in the doStartTag() to set a request scoped attribute. or use the one in the jspContext by using pageContext.setAttribute("name",value,REQUEST_SCOPE);
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider a variable called temp at page level. Now i want to set value for this variable. is it possible to set value for this variable using custom tags?
if yes, please explain how it can be done.

Thanks and Regards,
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the attribute name temp is in page scope then you can set the value of that attribute in the doStartTag() by using pageContext.setAttribute("temp",value,PAGE_SCOPE); or by using pageContext.setAttribute("temp",value) because the default anyway is page scope.
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me put it like this.
Consider the following code
<html>
<body>
<%! int Counter=0; %>
//1
</body>
</html>

What should come in //1 if i want to set value for Counter using Custom Tags?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic