Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wrong page access count

 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • 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 ]
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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: 642
  • Mark post as helpful
  • send pies
  • 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
  • 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: 642
  • Mark post as helpful
  • send pies
  • 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!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic