wood burning stoves 2.0*
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: " + it.next());


and the BeerSelect servelet code is :

package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
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: " + it.next());
// }

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: http://aspose.com/file-tools
subject: Compiling result.jsp (page 89 HFSJ)
Similar Threads
HTTP Status 404 error in tomcat
Can't compile result.jsp page
Getting error when tryin to code Beer example from Head first Java Servlets
MVC + view.forward = loose coupling?
Why tomcat act like it error?