• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

problem refering a source javascript file in jsp

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67664
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using page-relative URLs in a web app will usually lead to such problems. See this JSP FAQ entry.
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67664
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
It will give me the powers of the gods. Not bad for a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic