Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > get static variable from class into JSP tag scope

Reply
Thread Tools

get static variable from class into JSP tag scope

 
 
Robert Mark Bram
Guest
Posts: n/a
 
      01-22-2008
Hi All,

I have a static variable in a class that I wish to share with some of
my JSP code. Can I use the <jsp:useBean> (or any tag?) to get that map
into the scope of my JSP tags?

Thanks for any assistance,

Rob

 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      01-23-2008
Robert Mark Bram wrote:
> Hi All,
>
> I have a static variable in a class that I wish to share with some of
> my JSP code. Can I use the <jsp:useBean> (or any tag?) to get that map
> into the scope of my JSP tags?


<jsp:useBean> requires that the bean be in scope, i.e., entered into the
context of the page, request, session or application, e.g., via
<http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#setAttribute(java.lang.String, %20java.lang.Object)>

You can also use Expression Language (EL) to access such beans.

You could also use scriptlet, but don't.

You could also use Java Server Faces (JSF), which has a way to directly
connect component attributes ('value', 'binding', 'action') to bean methods
and attributes. There is a learning curve involved there.

--
Lew
 
Reply With Quote
 
 
 
 
Hal Rosser
Guest
Posts: n/a
 
      01-23-2008

"Robert Mark Bram" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All,
>
> I have a static variable in a class that I wish to share with some of
> my JSP code. Can I use the <jsp:useBean> (or any tag?) to get that map
> into the scope of my JSP tags?
>
> Thanks for any assistance,
>
> Rob
>


try
<%@ page import = "yourpackage.YourClass" %>



 
Reply With Quote
 
Jonatan Kazmierczak
Guest
Posts: n/a
 
      01-23-2008
Hal Rosser wrote:
> "Robert Mark Bram" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi All,
>>
>> I have a static variable in a class that I wish to share with some of
>> my JSP code. Can I use the <jsp:useBean> (or any tag?) to get that map
>> into the scope of my JSP tags?
>>
>> Thanks for any assistance,
>>
>> Rob
>>

>
> try
> <%@ page import = "yourpackage.YourClass" %>
>
>
>

And after that:
<%= YourClass.VALUE %>

--
Regards,
Jonatan Kazmierczak
SCJP SCJD TC_rated_member Linux_user
Asm86 Bash C/C++ Java JavaScript Pascal Perl PHP Ruby TCL VB VBS XSLT
 
Reply With Quote
 
Robert Mark Bram
Guest
Posts: n/a
 
      01-23-2008
Hi Hal,

> try
> <%@ page import = "yourpackage.YourClass" %>


Sorry, I should have been more specific - I wanted to get the value
into the scope of my jsp tags, not a scriptlet. Thank you for your
response though.
 
Reply With Quote
 
Robert Mark Bram
Guest
Posts: n/a
 
      01-23-2008
Thank you Lew,

> > I have a static variable in a class that I wish to share with some of
> > my JSP code. Can I use the <jsp:useBean> (or any tag?) to get that map
> > into the scope of my JSP tags?

>
> <jsp:useBean> requires that the bean be in scope, i.e., entered into the
> context of the page, request, session or application, e.g., via
> <http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.ht...)>


This supports the MVC pattern quite strongly, so I am not as
disgruntled as I was at first - now I see a reason for it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread safety problems with function scope static variables vs class static private members Hicham Mouline C++ 5 12-19-2008 08:10 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
JSP <jsp:useBean ... /> tag: Difference between 'class' and 'type' Sean Aitken Java 3 10-21-2004 11:35 AM
IMPORT STATIC; Why is "import static" file scope? Why not class scope? Paul Opal Java 12 10-10-2004 11:01 PM
How to embed the <jsp:plugin> tag into a tag handler class...HELP !! jstack Java 1 07-04-2003 06:58 PM



Advertisments