Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forwarding request to jsp page from servlet not showing correctly

 
rajats sharma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am creating a web app with JSP and servlet but getting some problem.
I have Login Page ( login.jsp) , UserPage.jsp( After login this page will appear with user session) and servlet (LoginConfirm.java)

Work Flow: That i want in my web app :
When my login will fail then servlet will set some message ( request.setAttribute("message", message); ) in request and will forward this with
RequestDispatcher rd = getServletContext().getRequestDispatcher("/login/login.jsp");
rd.forward(request, response);
[Above login is folder under WebContent of project and this folder is containing login.jsp and UserPage.jsp]

Problem which i am getting :

when login fails then servlet is forwading request to login.jsp with message but its failed to load CSS and Java Scripts files mention in login.jsp.
and all scripts and css files contains <html><head> tags with Tomcat error .

Thanks
 
Chris Barrett
Bartender
Pie
Posts: 317
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember the browser is going to make a request for the CSS and JavaScript files (or any other linked resource) in a place relative to the address where it thinks your page is. In this case the path in your url-pattern.

Check the links in the login.jsp to make sure they are relative to the address showing in your browser's address window or (better) don't use relative links. Most likely Tomcat is attempting to generate it's default 404 page (which is why you are finding all the scripts and CSS files contain <html><head> tags).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see the JspFaq for an article on properly creating resource URLs. They should be server-relative, starting with the context path.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic