posted 13 years ago
I m trying to work on a simple JSP application
Thats my index.jsp
<html>
<head>
<title>Select Your Portal</title>
</head>
<body>
<h1>Select your preferred portal:</h1>
<form name="form1" action="showportal.jsp" method="get">
<select name="portchoice">
<option>news</option>
<option>weather</option>
<option>entertainment</option>
</select>
<input type="submit" value="Click on ME">
</form>
</body>
</html>
Below is showportal.jsp
<%@ taglib prefix="c" uri='http://java.sun.com/jsp/jstl/core" %>
<html>
<c:choose>
<c:when test="${param.portchoice=='news'}">
<jsp:include page="news.jsp"/>
</c:when>
<c:when test="${param.portchoice=='weather'}">
<jsp:include page="weather.jsp"/>
</c:when>
<c:when test="${param.portchoice=='entertainment'}">
<jsp:include page="entertainment.jsp"/>
</c:when>
<c:otherwise>
<jsp:include page="problem.jsp"/>
</c:otherwise>
</c:choose>
</html>
and below is news.jsp
<html>
<head>
<title>News Portal</title>
</head>
<body>
<jsp:useBean id="newsfeed" class="com.wrox.begjsp.ch2.NewsFeed" scope="request">
<jsp:setProperty name="newsfeed" property="topic" value="news"/>
<jsp:getProperty name="newsfeed" property="value" />
</jsp:useBean>
<jsp:include page="dummytext.html"/> <!-- dummytext.html is a dummy.html file-->
</body>
</html>
The application is giving the error below when I select New from the index.jsp and click on "Click on Me"
org.apache.jasper.JasperException: /ex2/showportal.jsp(5,41) equal symbol expected
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:198)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:148)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:408)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:499)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1558)
org.apache.jasper.compiler.Parser.parse(Parser.java:130)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:245)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:161)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:307)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:309)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
Below is my NewsFeed.java file :
package com.wrox.begjsp.ch2;
import java.beans.*;
import java.util.*;
public class NewsFeed extends Object implements java.io.Serializable {
private String topic;
private String value;
private ArrayList values;
public NewsFeed() {
}
public void setTopic(String topic) {
value = "";
values = null;
if (topic.equals("news")) {
value = "JSP Programmer Won 10 Million in Lottery";
}
if (topic.equals("entertainment")) {
value = "Reality TV Show Ratings Falling";
}
if (topic.equals("weather")){
values = new ArrayList();
HashMap tmap = new HashMap();
tmap.put("city", "Mumbai");
tmap.put("temp", "30 C");
values.add(tmap);
tmap = new HashMap();
tmap.put("city", "Tokyo");
tmap.put("temp", "18 C");
values.add(tmap);
tmap = new HashMap();
tmap.put("city", "Hong Kong");
tmap.put("temp", "28 C");
values.add(tmap);
}
}
public String getValue() {
return this.value;
}
public ArrayList getValues() {
return this.values;
}
}
Thanks in advance. I m confused with what would be the exact problem with this one.
Thanks,
Asad