You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by An...@fiducia.de on 2006/08/28 15:10:34 UTC

Defining dynamic default value for a cookie

Hello!

I'm trying to define a default value in the jsp for a cookie, but I don't know
how to do it :-(.

I've go the following piece of code:

...
<bean:write name="Integrationmenuform" property="pname"/>
<bean:cookie id="cpname" name="CookieCname" value=""/>
...

I would like to have the output from the bean:write - tag as input for the value
in the bean::cookie - tag:
<bean:cookie id="cpname" name="CookieCname" value='<bean:write
name="Integrationmenuform" property="pname"/>'/> does not work (the bean:write -
tag without the cookie - tag works fine).

Which way must the bean:cookie - tag be written to get a dynamic default value?


Thanks for any hint,
kind regards,
Andreas Hartmann


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Defining dynamic default value for a cookie

Posted by Andreas Hartmann <an...@freenet.de>.
Hello Puneet!

Puneet Lakhina wrote:
> On 8/28/06, Andreas.Hartmann@fiducia.de <An...@fiducia.de> wrote:
>>
>>
>> Hello!
>>
>> I'm trying to define a default value in the jsp for a cookie, but I don't
>> know
>> how to do it :-(.
>>
>> I've go the following piece of code:
>>
>> ...
>> <bean:write name="Integrationmenuform" property="pname"/>
>> <bean:cookie id="cpname" name="CookieCname" value=""/>
>> ...
>>
>> I would like to have the output from the bean:write - tag as input for the
>> value
>> in the bean::cookie - tag:
>> <bean:cookie id="cpname" name="CookieCname" value='<bean:write
>> name="Integrationmenuform" property="pname"/>'/>
> 
> Try
> <bean:cookie id="cpname" name="CookieCname"
> value='<%=((YourType)request.getAttribute("Integrationmenuform")).getPname()%>'
> />
> This is assuming your bean is in request scope, make appropriate changes
> incase the bean is in session scope.

Yes, it's in the request scope. Should work. I'll test it tomorrow. It's
really a pity that the struts taglibs don't work in any case. Will there
be a solution in the future :-)?

> 
> Dont think this solution is pleasing to the eye....:-)

If it works ... .


Thanks for yout hint,
kind regards,
Andreas Hartmann

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Defining dynamic default value for a cookie [*]

Posted by An...@fiducia.de.
Hello Puneet!

I could solve my problem now on my own :-). I addressed the class directly in
the jsp-file:

<bean:cookie id="cpname" name="CookieCname"
value='<%=((de.fiducia.integration.Integrationmenuform)request.getAttribute("Integrationmenuform")).getPname()%>'/>
<bean:cookie id="cvrm" name="CookieCvrm"
value='<%=((de.fiducia.integration.Integrationmenuform)request.getAttribute("Integrationmenuform")).getVrm()%>'/>

The created symlinks I mentioned in the other post are not needed any more.


Kind regards,
Andreas Hartmann


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Antwort: Re: Defining dynamic default value for a cookie [*]

Posted by An...@fiducia.de.
Hello Puneet,

I tried your solution, but I'm getting now another error:

Generated servlet error:
Integrationmenuform cannot be resolved to a type

I wrote the following in the jsp:

<bean:cookie id="cpname" name="CookieCname"
value='<%=((Integrationmenuform)request.getSession().getAttribute("Integrationmenuform")).getPname()%>'/>
<bean:cookie id="cvrm" name="CookieCvrm"
value='<%=((Integrationmenuform)request.getSession().getAttribute("Integrationmenuform")).getVrm()%>'/>


My web.xml from conf-dir with the init-params:

    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>



I straced the java-container and detected, that there is an attempt to load
Integrationmenuform at another place. Therefore, I created some symlinks in
order to give the java container the requested class. I set the created
directories to the tomcat user. This is, what I can see after I created the
symlinks:

....
5880  stat("/opt/apache-tomcat-5.5.17
/webapps/integration_portalmanagement/WEB-INF/classes/org/apache/jsp/pages/Integrationmenuform.class",
 {st_mode=S_IFREG|0644, st_size=9084, ...}) = 0
5880  access("/opt/apache-tomcat-5.5.17
/webapps/integration_portalmanagement/WEB-INF/classes/org/apache/jsp/pages/Integrationmenuform.class",
 R_OK) = 0
5880  stat("/home/tomcat/org/apache/jsp/pages/Integrationmenuform.class",
0x412501b0) = -1 ENOENT (No such file or directory)
5880  stat("/opt/apache-tomcat-5.5.17
/common/classes/org/apache/jsp/pages/Integrationmenuform.class", 0x41250210) =
-1 ENOENT (No such file or directory)
...

I can't find any open ... . I don't know, why struts doesn't want to load it. Do
you have an idea?


Thanks for your help,
kind regards,
Andreas Hartmann


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Defining dynamic default value for a cookie

Posted by Puneet Lakhina <pu...@gmail.com>.
On 8/28/06, Andreas.Hartmann@fiducia.de <An...@fiducia.de> wrote:
>
>
> Hello!
>
> I'm trying to define a default value in the jsp for a cookie, but I don't
> know
> how to do it :-(.
>
> I've go the following piece of code:
>
> ...
> <bean:write name="Integrationmenuform" property="pname"/>
> <bean:cookie id="cpname" name="CookieCname" value=""/>
> ...
>
> I would like to have the output from the bean:write - tag as input for the
> value
> in the bean::cookie - tag:
> <bean:cookie id="cpname" name="CookieCname" value='<bean:write
> name="Integrationmenuform" property="pname"/>'/>

Try
<bean:cookie id="cpname" name="CookieCname"
value='<%=((YourType)request.getAttribute("Integrationmenuform")).getPname()%>'
/>
This is assuming your bean is in request scope, make appropriate changes
incase the bean is in session scope.

Dont think this solution is pleasing to the eye....:-)
-- 
Puneet