• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting Exception in JSP

 
vinoth subramaniam
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Please help me on this one.

i am getting org.apache.jasper.JasperException. i dont know whats the reason. This is a sample programme from the head first JSp & servlets.

i am getting error at this step

17 : "Cookie cookie = cookies[i];"

error message is :

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP at stpe 17


Please help me to solve this prob. Thanks in advance
 
Gopikrishna Kunisetty
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please post the complete program?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vinoth,


you did not post any error message?

what is your problem?
 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vinoth subramaniam:
Hi all,
Please help me on this one.

i am getting org.apache.jasper.JasperException. i dont know whats the reason. This is a sample programme from the head first JSp & servlets.

i am getting error at this step

17 : "Cookie cookie = cookies[i];"

error message is :

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP at stpe 17


Please help me to solve this prob. Thanks in advance



Hi Vinoth,

We suggest you to be very clear in whatever you are trying to ask. We couldn't get your question at all.
 
vinoth subramaniam
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


code :
Cookkie[] cookies = request.getCookkies();

if (cookies != null)
{
for(int i=0;i<=cookies.length;i++)
{
Cookkie cookkie = cookkies[i];
out.println("hello"+cookie.getValue());
}
}








Error message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /pages/resultCookkie.jsp:17

14: {
15: for(int i=0;i<=cookkies.length;i++)
16: {
17: Cookkie cookkie = cookkies[i];
18: out.println(cookie.getValue());
19: }
20: }


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Srvlet_cookie.doPost(Srvlet_cookie.java:42)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.ArrayIndexOutOfBoundsException: 1
org.apache.jsp.pages.resultCookie_jsp._jspService(resultCookie_jsp.java:57)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Srvlet_cookie.doPost(Srvlet_cookie.java:42)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.


 
vinoth subramaniam
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just changed the spelling of the cookie, because i cant post the code having phrases like "get
cookie" (here too).
 
Gopikrishna Kunisetty
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, clearly it seems to be index range problem. Modify your code at line 15:

for(int i=0;i<=cookies.length;i++)

change this to

for(int i=0;i<cookies.length;i++)
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




see here the culprit[remove one k]
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vinoth, before posting the code please double check your spelling mistakes...every post your code is keep on changing
 
vinoth subramaniam
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
--------------
Hi, clearly it seems to be index range problem. Modify your code at line 15:

for(int i=0;i<=cookies.length;i++)

change this to

for(int i=0;i<cookies.length;i++)

--------------------
- Krishna
SCJP 1.4 SCWCD 1.5



Thank you Gopikrishna ... its index range problem. Thank you all, for your valuable time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!