aspose file tools*
The moose likes Struts and the fly likes Adding javascript to struts 2 jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Adding javascript to struts 2 jsp" Watch "Adding javascript to struts 2 jsp" New topic
Author

Adding javascript to struts 2 jsp

Abhilash Chander
Ranch Hand

Joined: Oct 18, 2009
Posts: 39
Hi All,
I'm trying to add my javascript file into my jsp page but it is not working. Im using struts 2.0.11 version and code I'm using is




javascript file and jsp are in the same folder. Can anybody help me out. Thanks in advance.

regards
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9317
    
  17

I'm trying to figure out what this question has to do with struts. Are you requesting the JSP directly?? With a URL which looks something like this: http://localhost:8080/Context/page.jsp or are you sending your request to a struts action?? Where you put the JSP and JS file on the server doesn't matter as the browser sends a separate request for the JS file.... Please tell us the URL that you are using to request this JSP and the directory structure where the JSP and JS files are...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Hi Abhilash Chander,

Have you checked the path of javascript file?? If you are using struts2 ,then build you can build script tag using <s:url> tag or do remember to add context path.

--
A.A.Anbarasu


A.A.Anbarasu
Abhilash Chander
Ranch Hand

Joined: Oct 18, 2009
Posts: 39
Thanks Anbarasu, Can you give me an example, when you say the context path. What you mean here is the absolute path of the file. ???
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Hi,

1)

2)



Note:
if you use struts2 url tag, it adds context path by default.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding javascript to struts 2 jsp