I'd vote for using JSTL: when standard functionality overlaps with something
you implement yourself, it's always better to opt for standard
functionality. It makes the JSP easier to understand for those unfamiliar
with custom functionality implemented at the action level.

Dave

On Thu, Oct 14, 2010 at 10:54 AM, Robert Taylor <[email protected]>wrote:

> 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]
>
>

Reply via email to