aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes problem refering a source javascript file in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "problem refering a source javascript file in jsp" Watch "problem refering a source javascript file in jsp" New topic
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
    
  13

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
    
  13

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem refering a source javascript file in jsp
 
Similar Threads
javascript in JSP
Javascript Error after response is Sent
Javascript code inside JSP (error in flushing)
File Upload using commons-fileupload-1.0
ServletException: bean not found within scope