This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes wrong page access count Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "wrong page access count " Watch "wrong page access count " New topic
Author

wrong page access count

Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Hi,
I am writing a simple JSP that writes the user info (firstname, lastname and email) to a text file. This JSP uses 2 Java classes(User and UserIno) that belong to 2 different packages(A and B). Part of the JSP (userinfo.jsp)is here:

This page is called by an HTML file. Everything works fine but any record that is entered on the HTML page is written thrice to the text file and the count is increased by 3 every time the page is accessed.
HTML code is below:

What could be wrong?
When I want to use a custom error page (404) - Error.jsp where should I include this page directive <%@ page errorPage="Error.jsp"%> in my JSP code to redirect it to the Error.jsp?
Thanks
Nandini
[ November 06, 2003: Message edited by: Nandini Sriram ]

Discipline, Dedication and Determination define Destiny.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
Nandini,
Your first problem is really strange cant guess anything,may be it will help if u post code of UserIO.addRecord() method.
And about inluding the page directive you can inlud it at starting of your jsp page,but it will not call your Error.jsp for 404 error!!
404 means server is not able to find ur file,so it cant execute it and hence cant fwd this error to Error.jsp.
for redirecting 404 error you have to try adding following tag in web.xml

<error-page>
<error-code>404</error-code>
<location>/jsp/Erropage.jsp</location>
</error-page>
cheers
Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Hi Praful,
Thank you for your suggestions. I did include those lines in web.xml, but the usual error page(of the IE) - "The page cannot be found" only comes and not my Error.jsp.
Here's the code for addRecord() of the class UserIO:

Also please take a look at my directory structure:
webapps
|
|----MyApp
|
|---WEB-INF
| |---classes (my servlets,class files here)
| |---web.xml
|
|---MyJsp(my JSP and HTML files here)

I run my HTML file (that calls a JSP file) like this:
http://localhost:8080/MyApp/MyJsp/sample1.html--It works fine with the corresponding JSP getting called.
However, when I try to call a servlet, it doesn't work.
http://localhost:8080/MyApp/SomeServlet. Is my servlet file's location correct?
Regards
Nandini
[ November 07, 2003: Message edited by: Nandini Sriram ]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

Go to Help->options->advanced tab->
then select Display/Show friendly URLs

[ November 07, 2003: Message edited by: Pradeep Bhat ]

Groovy
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Thanks Pradeep. But it doesn't seem to work even when the option is turned on. I'll look into again.
Regards
Nandini
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
Nandini,
Try putting <error-page>... tag in web.xml which resides in Tomcat/conf/.
Also in same web.xml check out for following entry,if this is commented(defalut it will be commented) then uncomment it,restart tomcat and try ur luck again with servlet
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
do let us know if it works
cheers
Praful
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Praful,
Thanks. I did what you told me, but any changes I make to the web.xml results in a pop-up saying Application popup: Explorer.EXE - Application Error : The instruction at "0x63611a1e" referenced memory at "0x00000000". The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
. Also the webserver doesn't start up. Don't know where I'm making a mistake.
Regards
Nandini
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
Nandini,
just remove the entry of <error-page>.... from tomcat/conf/web.xml(one which you have added as per my last post)
and try to restart tomcat.
Also let me know version of your tomcat.
Cheers!!
 
 
subject: wrong page access count
 
Similar Threads
JSP makes me headache
Doubt on calling Servlet from JSP
jsp:useBean id not clear
simple jsp:JasperException
use of value object ( javabeans )