aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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
Author

Compiling result.jsp (page 89 HFSJ)

Chris Jr
Greenhorn

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 ...


Chrisjr
Karen Jirak
Greenhorn

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

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

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

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

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

</body>
</html>


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 {
//response.setContentType("text/html");

//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
Greenhorn

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
Greenhorn

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

Thanks a lot.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compiling result.jsp (page 89 HFSJ)