Thank you, this works. I would like to draw your attention to possible problems 
with the struts head tag. See below.

<head>
<title>Domain Security Administrator: Pas gebruiker aan</title>
<link href="<c:url value="/css/domainsecurityadmin.css"/>" rel="stylesheet" 
type="text/css">
<script src="<c:url value="/js/util.js"/>" type="text/javascript"></script>
<script src="<c:url value="/js/domainsecurityadmin.js"/>" 
type="text/javascript"></script>
</head>

is converted into:

<head>
<title>Domain Security Administrator: Pas gebruiker aan</title>
<link href="/domainsecurityadmin/css/domainsecurityadmin.css" rel="stylesheet" 
type="text/css">
<script src="/domainsecurityadmin/js/util.js" type="text/javascript"></script>
<script src="/domainsecurityadmin/js/domainsecurityadmin.js" 
type="text/javascript"></script>
</head>

----- Struts head tag problems.

However, there could be a problem when the <s:head> tag has to be included for 
one reason or another.

In that case:

<head>
<title>Domain Security Administrator: Pas gebruiker aan</title>
<link href="<c:url value="/css/domainsecurityadmin.css"/>" rel="stylesheet" 
type="text/css">
<script src="<c:url value="/js/util.js"/>" type="text/javascript"></script>
<script src="<c:url value="/js/domainsecurityadmin.js"/>" 
type="text/javascript"></script>
<s:head/>
</head>

is converted into:

<head>
<title>Domain Security Administrator: Pas gebruiker aan</title>
<link href="/domainsecurityadmin/css/domainsecurityadmin.css" rel="stylesheet" 
type="text/css">
<script src="/domainsecurityadmin/js/util.js" type="text/javascript"></script>
<script src="/domainsecurityadmin/js/domainsecurityadmin.js" 
type="text/javascript"></script>
<link rel="stylesheet" href="/domainsecurityadmin/struts/xhtml/styles.css" 
type="text/css"/>
<script src="/domainsecurityadmin/struts/utils.js" 
type="text/javascript"></script>
</head>

which causes the following errors to be shown in the chrome javascript console:

Failed to load resource: the server responded with a status of 404 (Not Found) 
utils.js
Failed to load resource: the server responded with a status of 404 (Not Found) 
styles.css

No idea what utils.js and styles.css are.

When adding theme="simple" to the head tag only the utils.js error message is 
generated.




-----Oorspronkelijk bericht-----
Van: Robert Taylor [mailto:[email protected]] 
Verzonden: donderdag 14 oktober 2010 16:54
Aan: Struts Users Mailing List
Onderwerp: Re: referencing javascript files from (action) jsp file

Or you could simply use JSTL.
The following works for me:
<script type="text/javascript" src="<c:url 
value="/javascript/jquery/jquery-1.4.2.min.js"/>"></script>



/robert

----- Original Message ----- 
From: "Li Ying" <[email protected]>
To: "Struts Users Mailing List" <[email protected]>
Sent: Thursday, October 14, 2010 10:33 AM
Subject: Re: referencing javascript files from (action) jsp file


>I suggest you to reference your resource file(js, image, css and so
> on) in this way:
>
> <script type="text/javascript" src="<s:property value="contextPath"
> />/path/filename.js"></script>
>
>
> The [<s:property value="contextPath" />] part will
> render the contextPath where the web application
> is deployed.
>
> The [contextPath] is a property defined in Action:
> public String getContextPath() {
> return ServletActionContext.getServletContext().getContextPath();
> }
>
> I put this property in the supper class of all of the Action classes
> so i can reference this property in all the pages
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




-------------
Aan dit bericht kunnen geen rechten worden ontleend. Alle berichten naar dit 
professioneel e-mailadres kunnen door de werkgever gelezen worden.
Ondernemingsnummer: 0253.973.219

Reply via email to