I really hope someone can help with this problem! ;-) ...
I have setup a project whereby I have currently placed all my .jsp files outside of the WEB-INF folder, as though they were regular html files. Each jsp file has an include to a header, navigation and footer jsp fragment plus the CSS link, i.e.
<jsp:include page="jspf/header.jspf"/>
All images are accessed relative to the context path, i.e.
<img src="images/logo-full.jpg"></img>
But for some reason, when my JSP 'registration page' submits its form, although it processes my Servlet successfully, the 'forward' within the servlet seems to screw a few things up.
1) Images and CSS get lost
2) My EL expressions seem to be treated as literal text
Here's the line of the form that shows my action to the servlet...
<form id="tenantRegistrationForm" action="servlets/TenantRegistration" method="POST">
Here's the main lines in my TenantRegistration servlet that sets up a request attribute and then tries to perform the forward..
if (error.length()>0) {
// ** need to store in the request scope **
request.setAttribute("error",error.toString());
}
request.getRequestDispatcher("/registrationSuccess.jsp").forward(request, response);
A few things then go horribly wrong. My images and CSS all dissapear, when I do a view source prior to going to my servlet the paths are correct, but afterwards when the servlet has forwarded to a new JSP the paths are incorrect. When it's working my logo can be found here
http://localhost:8080/Aim2MoveWebsite/images/logo-small.gif
but when it goes wrong it changes to
http://localhost:8080/Aim2MoveWebsite/servlets/images/logo-small.gif
I'm not sure why it is inserting 'servlets' into the page?
Lastly, none of my expression language display anything - I have the correct JSTL 1.1 tag lib
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
Here's a portion of the JSP file that's meant to show at least some of the values (I did do a debug and confirmed that the 'error' attribute did exist in the request scope)...
A -> <c:out value="${requestScope['error']}"/>
B -> <c:out value="${requestScope[error]}"/>
C -> <c:out value="${requestScope.error}"/>
D -> <c:out value="${pageContext.request}"/>
E -> <c:out value="${pageContext.request['error']}"/>
F -> <c:out value="${pageContext.request[error]}"/>
G -> <c:out value="${error}"/>
What I see on the screen is as though the ${} is not being parsed?! WTF. I am using Netbeans and included the JSTL 1.1 library. Here's what I see
A -> ${requestScope['error']} B -> ${requestScope[error]} C -> ${requestScope.error} D -> ${pageContext.request} E -> ${pageContext.request['error']} F -> ${pageContext.request[error]} G -> ${error}
Please help, I promised someone that I would finish this 'simple' website by the weekend :-(
Thanks,
Rob.