Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JspWriter cannot be resolved to a type

843840Apr 18 2010 — edited Apr 18 2010
The following is CheckAddress.jsp page which checks if the form has the name and phone fields filled in or not. If not then it must print the errors. But the problem I am having is that the Eclipse is showing me the error "JspWriter cannot be resolved to a type".

If I ignore this error and run the page in the j2ee preview server in eclipse than I get the following error:
>
Unable to compile class for JSP

An error occurred at line: 22 in the jsp file: /CheckAddress.jsp
Generated servlet error:
The method prinln(String) is undefined for the type JspWriter

An error occurred at line: 22 in the jsp file: /CheckAddress.jsp
Generated servlet error:
The method prinln(String) is undefined for the type JspWriter

An error occurred at line: 22 in the jsp file: /CheckAddress.jsp
Generated servlet error:
The method prinln(String) is undefined for the type JspWriter



Caused by:
org.apache.jasper.JasperException: Unable to compile class for JSP
>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<%--Provide Directives to inform JSP of packages needed--%>
<%@page language="java" import="java.util.*"%>
<%@page language="java" import="java.io.*"%>

<%--Specify JSTL tag library for use --%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<meta http-equiv="Content-Type" content="text/html; charaset=ISO-8859-1">
<title>Check Address</title>
</head>
<body>
<%--Declare the java bean for the addresslist to be queried --%>
	<jsp:useBean id="dbab" class="addressBean.DBAddressBean" />
	
<%--Use JSP scripting elements to define two methods --%>
<%!
	List<String> checkAddress(String Name, String Phone){
	 List<String> errors = new ArrayList<String>();
	 if((Name == null) || (Name.equals(""))){
		 errors.add("Name must not be blank");
	 }
	 if((Phone == null)||(Phone.equals(""))){
		 errors.add("Phone must not be blank");
	 }
	 
	 return errors;
	}

	void printErrors(JspWriter out, List<String> errors) throws IOException{
		//Report the errors
		out.prinln("<p class=\"error1\">The following errors occured: <br />");
		out.prinln("<ul>");
		Iterator<String> i = errors.iterator();
		while(i.hasNext()){
			out.println("<li type=\"disc\">"+i.next()+"</li>");
		}
		out.prinln("</ul></p><p><b>please try again</b></p><br />");
	}
	
%>	

<%--Use the internal Scriptlet to call an internal method and get the request parameters with the form info--%>
<% 
	List<String> errors = checkAddress(request.getParameter("Name"), request.getParameter("Phone"));
%>
<%--Use JSTL tags to get the values of the parameters for all of the form info --%>

	<c:set var="aid" value="${param.aid}"/>
	<c:set var="Name" value="${param.Name}"/>
	<c:set var="Street" value="${param.Street}"/>
	<c:set var="City" value="${param.City}"/>
	<c:set var="State" value="${param.State}"/>
	<c:set var="Zip" value="${param.Zip}"/>
	<c:set var="Phone" value="${param.Phone}"/>
	
<%--Use JSP elements to set the values in the Java Beans--%>
	
	<jsp:setProperty name="dbab" property="id" value="${aid}"/>
	<jsp:setProperty name="dbab" property="name" value="${Name}"/>
	<jsp:setProperty name="dbab" property="street" value="${Street}"/>
	<jsp:setProperty name="dbab" property="city" value="${City}"/>
	<jsp:setProperty name="dbab" property="state" value="${State}"/>
	<jsp:setProperty name="dbab" property="zip" value="${Zip}"/>
	<jsp:setProperty name="dbab" property="phone" value="${Phone}"/>
	
<%--Use the scriptlet to determine where to go now --%>
<%--Notice how the JSP element tag is used within the scriptlet, the scriptlet needs to be "closed" and "reopened"--%>

<%
	if(errors.size()==0){
		dbab.saveChanges();
		response.sendRedirect("AddressList.jsp");
	}else{
		//print errors
		printErrors(out, errors);
	
	
%>		
	<jsp:include page="EditAddress.jsp"/>
<% 
	}
%>	
</body>
 
Edited by: blinkaj on Apr 18, 2010 2:15 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 16 2010
Added on Apr 18 2010
2 comments
2,794 views