james
james

Reputation: 1677

JSP compiled but now has several errors?

I have a JSP and Servlet project on github at - https://github.com/double-whammy/affablebean.git . This code at least compiled properly on my old computer. When I imported it into my new computer, it shows me a lot of strange compile errors. I will show you some of the code and the errors. Please help me to correct this.

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/affablebean.css">
<title>The Affable Bean</title>
</head>
<body>

    <sql:query var="categories" dataSource="jdbc/affablebean">
    SELECT * FROM category
    </sql:query>

    <sql:query var="selectedCategory" dataSource="jdbc/affablebean">
    SELECT name FROM category WHERE id = ?
    <sql:param value="${pageContext.request.queryString}" />
    </sql:query>

    <sql:query var="categoryProducts" dataSource="jdbc/affablebean">
    SELECT * FROM product WHERE category_id = ?
    <sql:param value="${pageContext.request.queryString}" />
    </sql:query>

    <div id="categoryLeftColumn">

        <c:forEach var="category" items="${categories.rows}">

            <c:choose>
                <c:when test="${category.id == pageContext.request.queryString}">
                    <div class="categoryButton" id="selectedCategory">
                        <span class="categoryText"> ${category.name} </span>
                    </div>
                </c:when>
                <c:otherwise>
                    <a href="category?${category.id}" class="categoryButton">
                        <div class="categoryText">${category.name}</div>
                    </a>
                </c:otherwise>
            </c:choose>

        </c:forEach>

    </div>
</body>
</html>

The errors are:

Line <sql:param value="${pageContext.request.queryString}" /> :

Multiple annotations found at this line:
    - java.io.IOException cannot be resolved to a type
    - No exception of type ServletException can be thrown; an exception type must be a subclass of 
     Throwable
    - The method getQueryString() from the type HttpServletRequest refers to the missing type String
    - String cannot be resolved to a type

Line <sql:query var="categoryProducts" dataSource="jdbc/affablebean">

No exception of type JspException can be thrown; an exception type must be a subclass of Throwable

Line <c:forEach var="category" items="${categories.rows}">

Multiple annotations found at this line:
    - java.util.Map cannot be resolved 
     to a type

Upvotes: 0

Views: 3253

Answers (1)

james
james

Reputation: 1677

Google this error The method getQueryString() from the type HttpServletRequest refers to the missing type String without the getQueryString(). A SO post hints that this could be a problem with the default jre of the project (jdk actually if you are doing Java enterprise projects).

In eclipse, your project > right click > order and exports tab. The JRE system library should have a red cross next to it and status is unbound. Another SO post suggests that you need to change/fix the default jre or jdk for this.

In eclipse, window > preferences. Remove all the old Jres or Jdks and a jdk again. Add > Standard VM > Next > Find the folder where you installed jdk etc. > Finish.

Go back to your project properties. There should be an error next to JRE system library. Select it and remove it. Then, add library > add the Jre/jdk you just set in the previous step.

Rebuild and clean your project. Problem solved.

Upvotes: 1

Related Questions