aspose file tools*
The moose likes Servlets and the fly likes On forwarding request to jsp, its CSS and JScript files aren't loading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "On forwarding request to jsp, its CSS and JScript files aren Watch "On forwarding request to jsp, its CSS and JScript files aren New topic
Author

On forwarding request to jsp, its CSS and JScript files aren't loading

crazy programmer
Greenhorn

Joined: Oct 22, 2013
Posts: 1
I'm calling a servlet from a JSP page and setting some Attributes in servlet and finally calling ANOTHER JSP using RequestDispatcher's forward method. the second JSP is loading, showing the attributes that I've passed to it but none of the STYLESHEETS or jQuery/JAVASCRIPT files are loading into the page.

Error Msg: Upon Element Inspection in Mozilla of the forwarded JSP page I'm getting following error msg .

The stylesheet .../java/tutorial/mystyle.css was not loaded because its MIME type, “text/html”, is not “text/css”.

And for javascript its showing SYNTAX ERROR msg.

Without this forwarding if the JSP page is run, both the CSS and JavaScript called on this page are loading.

I've tried adding mime-mapping in my web.xml for css but still its not working.

I tried calling the second JSP page separately without servlet forwarding everything is working fine, stylesheets and javascripts are all loading.

How can I load my CSS and Javascript during Request forwarding ??

Thanks in advance
sachin naikwadi
Greenhorn

Joined: Oct 22, 2013
Posts: 7

verify the relative path for all the css and js files referenced in your jsp.
if your problem still exists then better post your code here...


Regards,
Sachin


Regards,
Sachin
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

You need to be using server-relative URLs for the resources. See the JspFaq for more details.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: On forwarding request to jsp, its CSS and JScript files aren't loading