Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  147] [ 6]  / answers: 1 / hits: 18124  / 11 Years ago, fri, march 15, 2013, 12:00:00

So in eclipse when you generate a .jsp file it automatically includes the following top line:



<%@ page language=java contentType=text/html; charset=ISO-8859-1
pageEncoding=ISO-8859-1%>


Is there a way to also include javascript code so that I can have some of the file written in java and some written in javascript?


More From » java

 Answers
16

The answer is Yes, you can add the js in jsp. And this also has benefit. It helps you to use the values stored in request and session, because the js code which contains the jsp stuff in jsp will be compiled while the *.js file will not. And also you should keep in mind that you'd better put the js code in .js file not in jsp, so the browser doesn't need to load it repeatly and code seems more clear, also good for debug. Another answer has give you the example code to import js file, so I just ignore it.


[#79582] Thursday, March 14, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
braidenv

Total Points: 80
Total Questions: 104
Total Answers: 91

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;