> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 07, 2003 9:35 AM
> To: [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to