File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CHAPTER 3 HF SERVLETS & JSP --- result.jsp compilation issues

 
Raguel Koning
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

Is there anyone who had the same issues I am having with chapter 3 of the Head First Servlets & JSP book?

Currently really struggling to compile the following JSP as per example on page 87 of the book.

<%@ page import="java.util.*"%>

<html>
<body>
<h1 align="center">Beer Recommendations JSP</h1>
<p>

<%
List styles = (List)request.getAttributes("styles");
Iterator it = styles.iterator();
while(it.hasNext()){
out.print("<br>try: " + it.next());
}
%>

</body>
</html>

It is returning the following exception, (I am pasting the root cause):

root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 8 in the jsp file: /result.jsp
Generated servlet error:
The method getAttributes(String) is undefined for the type HttpServletRequest


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)



Thanks
 
Mohd Fuzail
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we don't have request.getAttributes(String) method, but we have public java.lang.Object getAttribute(java.lang.String name) method.

Just remove an extra 's' and hope the JSP will compile

-Fuzail
"Being defeated is often a temporary condition. Giving up is what makes it permanent."
 
Raguel Koning
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much. I think I need a break... :-p

Cheers,

Raguel
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic