File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Javascript library not loading Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Javascript library not loading" Watch "Javascript library not loading" New topic
Author

Javascript library not loading

sri pathi
Greenhorn

Joined: Jul 15, 2008
Posts: 28
I open a jsp from another jsp using window.open
The child window has a javascript library included.
The child window has a form, which on submitting calls a servlet. After some processing there I do a RequestDispatcher.forward to the same page(child window) from the servlet. But this time when the child window reloads the javascript library is not loading. I see the message

"1Error 404: No target servlet configured for uri: /js/ratingsys.js" in firebug and hence the onload method of the body which needs to be executed is not executed.

Please let me know what could be the problem. Thanks in advance for all your time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56205
    
  13

The URL to your JS file is likely invalid.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
sri pathi
Greenhorn

Joined: Jul 15, 2008
Posts: 28
Nope! For the first time when I open the window using javascript(window.open), it works fine and it calls the onload method successfully. But the problem is when I do a RequestDispatcher.forward from the servlet the library is not loading and the onload method is not executing.
[ July 26, 2008: Message edited by: sri pathi ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56205
    
  13

OK then.
sri pathi
Greenhorn

Joined: Jul 15, 2008
Posts: 28
Originally posted by Bear Bibeault:
OK then.

I could not understand. Is my input not enough or I've sounded offensive in anyway?!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56205
    
  13

"Nope!" doesn't give any more useful information (and is a tad rude). You haven't shown us what URLs you are using, where the JS files are located, what resources you are forwarding to, or any other information that will help us help you.
sri pathi
Greenhorn

Joined: Jul 15, 2008
Posts: 28
Originally posted by Bear Bibeault:
"Nope!" doesn't give any more useful information (and is a tad rude). You haven't shown us what URLs you are using, where the JS files are located, what resources you are forwarding to, or any other information that will help us help you.


Originally posted by Bear Bibeault:
"Nope!" doesn't give any more useful information (and is a tad rude). You haven't shown us what URLs you are using, where the JS files are located, what resources you are forwarding to, or any other information that will help us help you.


I think this message might be too long, but bear with me.
Structure of my app:
Rating (application directory)
1. JavaSource
1.1 Java files in package structure
2. WebContent
2.1 js
2.1.1 javascript files (the javascript files reside here)
2.2 jsp
2.2.1 jsp files (jsp files, parent, child windows and other jsps)
2.3 css
2.3.1 the style sheet files (.css)
Parent Window:
parent.jsp

1. Has a link which when clicked (onclik method) calls a method from the library included as below.
<script type="text/javascript" src="../js/ratingsys.js"></script>
This part works absolutely fine.
child.jsp


3. ratingsys.js


My problem is with the child.jsp (when I open child.jsp from parent.jsp onclick method ratingsys.js loads properly and the javascript onload method transferdata executes properly). This child.jsp when submitted calls a servlet which after some processing does a RequestDispatcher.forward from the servlet to child.jsp again. But this time the javascript onload method transferdata does not execute. I see the following message in the firebug (firefox add on), "1Error 404: No target servlet configured for uri: /js/ratingsys.js")
But this time the rating sys

Please let me know if you need more details. Thanks in advance

[ July 26, 2008: Message edited by: sri pathi ]
[ July 26, 2008: Message edited by: sri pathi ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56205
    
  13

As I suspected:
Page-relative URLs are not valid in web applications where URLs generally reflect mappings rather than folder structures.

See the JSP FAQ on resource URLs to find out how to properly format resource URLs in a web application.
[ July 26, 2008: Message edited by: Bear Bibeault ]
sri pathi
Greenhorn

Joined: Jul 15, 2008
Posts: 28
Originally posted by Bear Bibeault:
As I suspected:
Page-relative URLs are not valid in web applications where URLs generally reflect mappings rather than folder structures.

See the JSP FAQ on resource URLs to find out how to properly format resource URLs in a web application.

[ July 26, 2008: Message edited by: Bear Bibeault ]

I think it fixed my problem, Thanks a lot! for your time!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Javascript library not loading
 
Similar Threads
Javascript child window
How do 2 pages generated from servlets pass value?
Hiding URL in pop-up window
Passing values from child to parent window
Popup window not working