Re: Trash appears in JSP page upon declaring error page



On Jul 28, 9:56 am, "phillip.s.pow...@xxxxxxxxx"
<phillip.s.pow...@xxxxxxxxx> wrote:
<%
     String errorURL = "https://"; + request.getServerName() + "/common/
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
.



Relevant Pages

  • Books - Sun Java Web component developer certification
    ... form parameters from the request, ... Section 4: Session Management ... The JavaServer Pages (JSP) Technology Model ... Building JSP Pages Using Tag Libraries ...
    (comp.lang.java.programmer)
  • Re: enctype=multipart/form-data on destination page, originating page, or both?
    ... thanks for your response bruce. ... the attributes in my form tag are changed dynamically as the form loads ... the server logic acts on those values. ... a hidden iframe to the server page. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: custom tags and content type
    ... My tag goes like: ... > I made some tests and if I set the mime type explicitly in the JSP like ... response type until the first char is sent - is not a standard and may ... change between servlet engines. ...
    (comp.lang.java.help)
  • Re: JSP and hashmaps containsKey
    ... I have a bean on my JSP page which is a HashMap. ... Is there a JSP/Struts tag that can access containsKey? ... I'm supporting an older app which currently does not use any JSTL. ...
    (comp.lang.java.programmer)
  • Re: Calling a jsp from within a jsp tag (is madness far away)
    ... this seems to work (in the tag handler) ... >apart from one which is a jsp type ... >The jsp fragment actually contains the name of the jsp (e.g ... >compiled at runtime and others at compile time but as I'm no JSP ...
    (comp.lang.java.programmer)