Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding javascript to struts 2 jsp

 
Abhilash Chander
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Anbarasu Aladiyan
Ranch Hand
Posts: 182
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Abhilash Chander
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 182
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

1)

2)



Note:
if you use struts2 url tag, it adds context path by default.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic