I know this was from a while back, but I just happen to be browsing the
archives a bit and decided to respond.

You mentioned that by using URLConnection the link to the server would not
have an active session. I solved this by getting the session id from the
request, and appending it to the url used in the URLConnection, so that the
request would be associated with the same session that was being requested
originally. The one problem I have with this approach is request parameters.
In general, my MVC framework forwards to a JSP page after some logic has
been performed. Part of the logic can often add request attributes. But when
using URLConnection, not only does the session ID not exist, you also have
to loop through every request parameter and append it to the url as well, in
order for the URLConnection url page to get the same request parameters that
were passed in from the original request. The problem with this is two fold.
First, it takes some cpu time to loop and append all these requests..and as
I can not just "pass" the original request on, this is something I don't
like to do on every single request to the server. Second, I forget why now,
but I came across some request limitations. Mainly, because forms are
submitted via a POST call from the browser (assuming you build JSP pages
with form POST calls), and the URLConnection uses a GET call, the GET call
seems to be limited to 256 or sometimes a few K total in length for the
request parameters. As I found out in a "dynamic" growable table I was
creating, this becomes a problem..if you keep appending more and more
request parameters, eventually you exceed that limit the GET can handle, and
I have no idea how to force URLConnection to use POST instead of GET.

Anyways, I tried your try/catch idea, and it still didn't work. I have yet
to figure out a way to get the compiler and/or runtime errors on a JSP page
retrieved by using URLConnection. I think it would require modification to
the JSP engine itself to somehow store these errors in the Web App Context
(as a global parameter), but then that wouldn't be thread safe. So I am not
sure if there is a way to actually do this yet.

Thanks for your ideas.



> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Janco Tanis
> Sent: Sunday, April 22, 2001 10:45 PM
> To: [EMAIL PROTECTED]
> Subject: Re: How to get JSP exception when using URLConnection to read
> in JSP
>
>
> You might put a try { } catch(ex)
stem.out.println(
> ex.printStackTrqace() ) }
> in your code.
>
> By the way, when using URLConnection to connect you should keep
> in mind that the
> 'server' acts as a browser and does not have an active session
> (which might even
> cause your exception) and definately does not use the session the
> browser created.
> So your jsp should be able to 'work' sessionless.
>
> regards,
> janco
>
>
>
> Kevin Duffey wrote:
>
> > For some reason, when a JSP page read in via code using
> URLConnection (thus,
> > it acts the same as if a browser were to request the JSP page,
> therefore the
> > output read in is the processed HTML the JSP page creates), I
> can't seem to
> > get any run time or compile time exceptions inside of my code. The only
> > thing I get is a FileNotFoundException because the JSP output was not
> > generated. Is there any way to get the exception the JSP engine
> generates
> > when a JSP page is read in in this manner?
> >
> > Thanks.
> >
> >
> ==================================================================
> =========
> > To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >  http://
www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> --
> Janco Tanis
>
> ------------------------------------------------------------
>       COAS, Your partner in computer aided services
>
>    Nijverheidsweg 34        Tel:   +31 (0) 187 49 3222
>    Postbus 44               Fax:   +31 (0) 187 49 2912
>    3250 AA Stellendam       Email: [EMAIL PROTECTED]
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to