Re: Trash appears in JSP page upon declaring error page
On Jul 28, 9:56 am, "phillip.s.pow...@gmail.com"
<phillip.s.pow...@gmail.com> wrote:
<%
String errorURL = "https://" + request.getServerName() + "/c=
ommon/
error/general_error.jsp";
%>
<%@ page errorPage = "<%= errorURL %>" %>
I believe this is your trouble right here. The <%= scriptlet tag says
to emit the enclosed text to the response 'out' stream. The <%@ JSP
metatag gives a directive to the JSP system, not an output to the
response. You can't mix them.
It's pretty much a mistake to set the error page from within the page
whose errors you're trying to catch. You'd be much better off setting
it from the web.xml.
<html>
<head>
<title>Blah</title>
</title>
Extra '</title>' here - invalid HTML.
</head>
<body>
Foo
</body>
</html>
The following URL, say, we call it "foo.jsp", once displayed, works
fine, except that this is your output:
%>
Foo
And the "%>" is found before the HTML tags are displayed, somehow
embedding this into the header. When I take out the <%@ page %> tag,
the "%>" disappears. I am required to reference the error page URL
within pages such as "foo.jsp", so how do I remove the extraneous
"trash" from the header, i.e. the "%>" from displaying?
Don't use scriptlet in the directive.
--
Lew