Servlet as Entry point, default Homepage

R

Robert Kattke

Need a little help on the Architecture of this WebApp!
I am building a website, in which I wanted to track stats on the
Referer.
String refString = req.getHeader("Referer");

I also need a particular variable "Metro Code" or "mcod", set before
any of the data-driven pages start to do queries and display
information. "mcod" can be set, stored and retrieved via either a
Cookie or Session variable.

Since I was doing some processing, I chose a Servlet as Entry point
(actually wrapped in a jsp).
<jsp:include page="servlet/ReffServ" flush="true" />

However, if "mcod" is not set, I need to direct the user to a pageform
to let them choose one, otherwise proceed to the main page. Any
attempt to Forward or Include either in Serlvet or JSP is giving me
errors like:
StackTrace java.io.IOException: Error: Attempt to clear a buffer
that's already been flushed
StackTrace java.lang.IllegalStateException: Cannot forward after
response has been committed

Suggestions ? Is there an Elegant Solution ? or not so Elegant one ?
TIA
 
B

Bryce

Have you considered using Filters?

Need a little help on the Architecture of this WebApp!
I am building a website, in which I wanted to track stats on the
Referer.
String refString = req.getHeader("Referer");

I also need a particular variable "Metro Code" or "mcod", set before
any of the data-driven pages start to do queries and display
information. "mcod" can be set, stored and retrieved via either a
Cookie or Session variable.

Since I was doing some processing, I chose a Servlet as Entry point
(actually wrapped in a jsp).
<jsp:include page="servlet/ReffServ" flush="true" />

However, if "mcod" is not set, I need to direct the user to a pageform
to let them choose one, otherwise proceed to the main page. Any
attempt to Forward or Include either in Serlvet or JSP is giving me
errors like:
StackTrace java.io.IOException: Error: Attempt to clear a buffer
that's already been flushed
StackTrace java.lang.IllegalStateException: Cannot forward after
response has been committed

Suggestions ? Is there an Elegant Solution ? or not so Elegant one ?
TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top