• 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

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

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much. I think I need a break... :-p

Cheers,

Raguel
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic