Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't render JSP

 
Grant Bryce
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Evening, I am new to JSPs and have been going through the Head First Servlets and JSP book. In chapter 3 a very simple MVC architecture is set up and the last step is to tie in the JSP. No matter what i do I can't seem to get he JSP to render, just getting a blank white page and no logged errors.

I have simplified the JSP to straight HTML to see if it was the issue but still no luck so it leads me to believe i am invoking it incorrectly.

here is the code, does anyone se what the issue could be or things i could try???

Thanks!!!

BTW: when i try and go straight to "http://localhost:8080/Beer-v1/result.jsp" i get the following stack trace:

org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/web.xml: (line 4, col 17)
org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:103)
org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:70)
org.apache.jasper.compiler.JspConfig.init(JspConfig.java:188)
org.apache.jasper.compiler.JspConfig.findJspProperty(JspConfig.java:240)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:160)

__________________________________
WEB.xml

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation= "http://java.sun.com/xml/ns/j2ee web-app_2.4.xsd"
version= "2.4">

<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>

__________________________________
BeerSelect.java

public class BeerSelect extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {

String c = request.getParameter("color");

BeerExpert be = new BeerExpert();
List result = be.getBrands(c);

request.setAttribute("styles", result);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request, response);
}
}

__________________________________
result.jsp
<html>
<body>
<h1 align="center">Beer Recommendations JSP</h1>
</body>
</html>
[ February 24, 2007: Message edited by: Bear Bibeault ]
 
Grant Bryce
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a hunch that my web-app declaration is incorrect for Tomcat 5.5. Does anyone have any feedback on that? I can't seem to find any current postings on that.

Cheers!


<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation= "http://java.sun.com/xml/ns/j2ee web-app_2.4.xsd"
version= "2.4">
 
Grant Bryce
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the stream of posts but it looks like i got it. I replaced the web-app declaration with this one i found on line and it works:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

I was missing the "http://java.sun.com/xml/ns/j2ee " which i can only presume allows the jsp's to compile?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Grant Bryce:
... which i can only presume allows the jsp's to compile?


No, it corrected whatever problem was causing:

org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/web.xml: (line 4, col 17)


which was preventing your web application from properly loading.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic