wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Query on Custom Tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Query on Custom Tags" Watch "Query on Custom Tags" New topic
Author

Query on Custom Tags

KRK Gowda
Ranch Hand

Joined: Nov 02, 2004
Posts: 132
Hi All,
how can we use Custom Tags to set value for JSP variables?

Thanks and Regards
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
KRK Gowda
Ranch Hand

Joined: Nov 02, 2004
Posts: 132
Not like that.
I want to know how to set JSP variables using Classic Tags or Simple Tags
Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
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);


if who i am is what i have, and what i have is lost, then who am i?<br /> <br />SCJP 5.0<br />SCWCD 1.4<br />SCBCD preparing
KRK Gowda
Ranch Hand

Joined: Nov 02, 2004
Posts: 132
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

Joined: Aug 12, 2006
Posts: 198
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

Joined: Nov 02, 2004
Posts: 132
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?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Query on Custom Tags
 
Similar Threads
PageContext and servletContext
web-app advice
Classsic Vs Simple?
Custom Tags
Prefix