File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Compiling result.jsp (page 89 HFSJ) 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 "Compiling result.jsp (page 89 HFSJ)" Watch "Compiling result.jsp (page 89 HFSJ)" New topic

Compiling result.jsp (page 89 HFSJ)

Chris Jr

Joined: Oct 19, 2005
Posts: 15
I am attempting to call jsp from the servlet as described in page 89 of HFSJ. I get this error.

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:
styles cannot be resolved

The servlet class compiled without any error. Any ideas ...

Karen Jirak

Joined: Sep 13, 2005
Posts: 25
Can you post your result.jsp file?
Chris Jr

Joined: Oct 19, 2005
Posts: 15
Sure. I am posting the result.jsp and the BeerSelect sevelet code. thanks.

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

<h1 align="center">Beer Recommendations JSP</h1>

List Styles = (List)request.getAttribute("styles");
Iterator it = styles.iterator();
out.print("<br>try: " +;


and the BeerSelect servelet code is :

package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class BeerSelect extends HttpServlet {
public void doPost (HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

//PrintWriter out = response.getWriter();

//out.println("Beer Selection Advice<br>");

String c = request.getParameter("color");

// out.println("<br>Got beer color " + c);

BeerExpert be = new BeerExpert();
List result = be.getBrands(c);

// Iterator it = result.iterator();
// while (it.hasNext()) {
//out.print("<br>try: " +;
// }

request.setAttribute("styles", result);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request, response);

Karen Jirak

Joined: Sep 13, 2005
Posts: 25
Hey Chris,

In your scriptlet code in result.jsp, when you declare the list styles you capitalize it, but in the next line it starts with a lowercase "s". I think maybe fixing that should fix your problem.
Chris Jr

Joined: Oct 19, 2005
Posts: 15
You are the man, Karen.

Thanks a lot.
I agree. Here's the link:
subject: Compiling result.jsp (page 89 HFSJ)
It's not a secret anymore!