struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Shneyderman" <a...@law.columbia.edu>
Subject RE: include javascript (urgent)
Date Mon, 07 Jul 2003 13:48:04 GMT


> -----Original Message-----
> From: harm@informatiefabriek.nl [mailto:harm@informatiefabriek.nl]
> Sent: Monday, July 07, 2003 9:35 AM
> To: struts-user@jakarta.apache.org
> Subject: include javascript (urgent)
> 
> Hi all,
> 
> I'm using the Struts framework for my web application.
> Unfortunatly I have to include some java-script from an other
webserver
> (Lotus Domino).
> 
> I have stored the url for the include in a Bean called: URLBean:
> 
> package ordermanager.urlbean;
> public class URLBean {
>         private String scriptFile;
>         public String getScriptFile() {
>                 return scriptFile;
>         }
>         public void setScriptFile(String string) {
>                 scriptFile = string;
>         }
> }
> 
> In my first Action I create the URLBean. And I add it to the session
> object using the following code:
> 
> URLBean urlBean = new URLBean();
> urlBean.setScriptFile(properties.getProperty("script.include"));
> request.getSession().setAttribute("urls", urlBean);
> 
> Then In my JSP I tried to do this:
> 
> <logic:present name="urls">
>         <jsp:useBean id="urls" scope="session"
class="ordermanager.urlbean
> .URLBean" />
>         ScriptFile: <bean:write name="urls" property="scriptFile"/>
<br/>
> </logic:present>
> 
> This code works... But I want to use this url in a <script> tag like
this:
> 
> <script src="<%= urls.getScriptFile() %>"></script>

This is impossible with the way you do it. You want to use it as a
context independent variable and yet you attach your bean to the session
context. You will have to declare and initialize the urls variable
somewhere in your script. Otherwise you can't get to it. So something
like this will work:

URLBean urls = (URLBean) request.getSession ().getAttribute ("urls");

But then again is it shorter or better than what you have already. I am
not so sure.



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


Mime
View raw message