GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes CHAPTER 3 HF SERVLETS & JSP --- result.jsp compilation issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "CHAPTER 3 HF SERVLETS & JSP --- result.jsp compilation issues" Watch "CHAPTER 3 HF SERVLETS & JSP --- result.jsp compilation issues" New topic
Author

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

Raguel Koning
Greenhorn

Joined: May 17, 2006
Posts: 12
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

Joined: Feb 20, 2002
Posts: 107
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."


Being defeated is often a temporary condition. Giving up is what makes it permanent.
Raguel Koning
Greenhorn

Joined: May 17, 2006
Posts: 12
Thank you so much. I think I need a break... :-p

Cheers,

Raguel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CHAPTER 3 HF SERVLETS & JSP --- result.jsp compilation issues