| Author |
problem refering a source javascript file in jsp
|
Abhishek Reddy
Ranch Hand
Joined: Mar 28, 2006
Posts: 259
|
|
i have a jsp file and iam using javascript file for form validations. <script type="text/javascript" src="form/build/jsfiles/validateform.js"></script> Directory structure of the application: ROOT/form/build/jsfiles/validateform.js when i open the page, iam getting an error the following error object is undefined. I have found out that my jsp file is unable to find the validateform.js file while displaying. tell me how to refer to js file which resides in subfolders as shown above. [ May 26, 2008: Message edited by: Bear Bibeault ]
|
Abhishek
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56179
|
|
|
Using page-relative URLs in a web app will usually lead to such problems. See this JSP FAQ entry.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Abhishek Reddy
Ranch Hand
Joined: Mar 28, 2006
Posts: 259
|
|
thanks for the reply, i have gone through the faq... iam using tomcat as a server and my application resides under ROOT folder of the webapps directory. when i try to get the contextPath of the application, iam getting an empty string. <%= request.getContextPath()%> then this will be same as giving pageurl, tell me how to get the contextPath when an application resides in ROOT folder of the webapps directory.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56179
|
|
|
What you are doing is correct. The context path of the ROOT app is the empty string. This does not mean that you can leave off the call to getContextPath(). By using it, your app will work no matter what the context path is.
|
 |
 |
|
|
subject: problem refering a source javascript file in jsp
|
|
|