tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: servlet and jsp application scope variable problem (easy?)
Date Wed, 07 Aug 2002 03:34:16 GMT


On Tue, 6 Aug 2002, Richard Diaz wrote:

> Date: Tue, 6 Aug 2002 19:58:52 -0700 (PDT)
> From: Richard Diaz <richdiaz99@yahoo.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: servlet and jsp application scope variable problem (easy?)
>
> in my servlet I create an application scope object and
> set its values. While -in- the servlet these values
> are correct. However, when I reference the application
> scope object in a JSP page (or in another servlet) all
> of its values are ZERO, not what I set them to.
>
> I -can- set the values of these object with JSP pages
> and the values STAY but I am using MVC and I don't
> want to give control to my JSP pages.
>
> I am having NO problems with my session variables.
>
> code in the SERVLET file:
>
> import myDomain.base.*;
> ...
> ServletContext context = getServletContext();
> ...
> Max TwcMax = new myDomain.base.Max();
> ...
> TwcMax.setbookmarks (99);
> ...
> context.setAttribute("myDomain.base.Max", TwcMax);
> ...
>
> Code in the JSP FILE:
> ...
> <jsp:useBean id="TwcMax" scope="application"
> class="myDomain.base.Max" />
> ...
> <%     TwcMax.setbookmarks(44);   %>
> ...

The name you use in the "id" attribute of a <jsp:useBean> must match the
attribute name under which you store your attribute.  Change your servlet
statement to:

  context.setAttribute("TwcMax", TwcMax);

and you'll have a lot better luck.

>
> I think that's all the code you need, I hope this is
> an easy problem, many thanks in advance for your
> help...
> Richard Diaz

Craig


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message