Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Cookies in Servlets and redirecting Servlet results to a JSP.

Cookies in Servlets and redirecting Servlet results to a JSP.

2006-11-23       - By Robbert

 Back

Hello,

After receiving some excellent help on my other topic, I thought I'd try
here again. This problem is related to the application I am making in my
other thread, but you needn't know the specifics. I'll just give you the
necessary information.

The webapp has to register hits and those have to be shown on a page named
Statistieken.jsp (which is located in /pages). This works.

My setup is as follows: The user visits /Statistieken (via the link going to
/Statistieken), then StatistiekServlet gathers the necessary data (HTTP
headers, URIs, etc.), stores it in a MySQL database (a rather simple and not
normalised one...) and is done. In web.xml I have /Statistieken mapped to
the StatistiekServlet.
Apparently, I have to track when a specific user last visited the page. And
I have to do that with cookies (yes, cookies...).

So my idea is as follows: a class, CookieServlet, uses getCookies() to
return a cookie array. If it's empty, there are no cookies set and a cookie
with the current number of hits for the statistics page will be set and the
statistics page will be shown.
If it's not, I iterate through it until I find the cookie I want. The value
in there (which is always a number to make things easier for me...) is
placed in an int with String.valueOf().
Then I use some basic SQL to determine the current number of hits, substract
the value in the cookie from the current number of hits to determine how
many visitors there have been since that person's last visit.

My questions are as follows:
- How can I get Statistieken.jsp to get the result of the subtraction
without using too much Java code in my JSP document? I'm thinking of making
an instance of the CookieServlet class and then calling the method that
returns the result of the subtraction and placing that in the JSP with a
scriptlet. Is this possible? And if so, is this the proper way for an MVC
structure?

- Given a Servlet that gets the records from the database, how do I get the
results in the ResultSet in the Servlet to the JSP and how do I iterate
through them without coding too  much logic in the JSP? Do I use tags or is
there some easier method?

Thanks for your help and if you need clarification: Ask away!
--
View this message in context: http://www.nabble.com/Cookies-in-Servlets-and
-redirecting-Servlet-results-to-a-JSP.-tf2692424.html#a7507983
Sent from the Tomcat - User mailing list archive at Nabble.com.


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.