This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Problem witn Request Dispatcher.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem witn Request Dispatcher.." Watch "Problem witn Request Dispatcher.." New topic
Author

Problem witn Request Dispatcher..

yogesh sood
Ranch Hand

Joined: Aug 31, 2000
Posts: 108
Hi all,

i have a JSP page in which im having one navigation bar created using JavaScript and DHTML.
all the javascript coding is done in seprate javascript file which i load in jsp using script tag

Now if i invoke that JSP directly from tomcat. Everything works fine Navigation bar is shown .

Now if i use RequestDispatcher from a servlet to call that JSP page Navigation Bar does not appear there is no script error.

I have checked this problem is occuring only when i use request dispatcher to call JSp Page . if i use send redirect then it works fine but if i use requestdispatch it does not work javascript file does not get loaded.


If its green its biology if its stinkks its chemistry if it has numbers it is Maths and if it doesn't work its TECHNOLOGY
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sounds like a URL path problem to me... what's the URL you're using to load the javascript file in the JSP?

If you're using a relative path, calling the JSP using RequestDispatcher will attempt to make the URL relative to the original caller (the servlet's) URL. If you send a redirect it makes the browser make a completely new request, so the relative URL will find the javascript file. Specify the full URL to the javascript file to fix this.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
yogesh sood
Ranch Hand

Joined: Aug 31, 2000
Posts: 108
thanks a lot !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem witn Request Dispatcher..
 
Similar Threads
Can't include .js file on jsp page controlled by front controller servlet
Loading a javascript file with file://
Excel Window problem
Problem retrieving session value in jsp pagess
Problem witn Request Dispatcher..