• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

wrong page access count

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go to Help->options->advanced tab->
then select Display/Show friendly URLs

[ November 07, 2003: Message edited by: Pradeep Bhat ]
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
reply
    Bookmark Topic Watch Topic
  • New Topic