org.apache.jasper.JasperException

Discussion in 'Java' started by minjie@excite.com, Apr 27, 2005.

  1. Guest

    Hello,
    I'm new to Java, Apache Tomcat, etc. I am going through the tutorial
    Coin Flip by NetBeans.org, but got the following exceptions when I
    tried to run the application on my Windows XP (the building of the app
    was fine):
    --------------------
    2005-04-27 13:26:32 StandardWrapperValve[jsp]: Servlet.service() for
    servlet jsp threw exception
    org.apache.jasper.JasperException: <h3>Validation error messages from
    TagLibraryValidator for fmt</h3><p>null: org.xml.sax.SAXParseException:
    Element or attribute do not match QName production:
    QName::=(NCName':')?NCName. </p>
    at
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
    at
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:411)
    at
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:76)
    at
    org.apache.jasper.compiler.Validator.validateXmlView(Validator.java:1535)
    at org.apache.jasper.compiler.Validator.validate(Validator.java:1481)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:214)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
    at
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
    at
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
    at
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at
    org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at
    org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    at
    org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at
    org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    at
    org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at
    org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
    at
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    at
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    at
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:534)
    -------------------

    The jsp page from the tutorial is as follows:
    ~~~~~~~~~~~~~~~~~~~~
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="\fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
    <html>
    <head><title>JSP Page</title></head>
    <body>
    <jsp:useBean id="tossesInfo" scope="session"
    class="org.me.coin.TossesBean" />
    <form action="Flip" method="post">
    <table>
    <tr>
    <th align="left">
    <font color="${(tossesInfo.heads) gt
    (tossesInfo.tails) ? 'green' : 'red'}">
    Heads
    </font>
    </th>
    <td><fmt:formatNumber
    value="${tossesInfo.heads}"/></td>
    <td><fmt:formatNumber value="${tossesInfo.pct_heads}"
    type="percent" /></td>
    </tr>
    <tr>
    <th align="left">
    <font color="${(tossesInfo.tails) gt
    (tossesInfo.heads) ? 'green' : 'red'}">
    Tails
    </font>
    </th>
    <td><fmt:formatNumber
    value="${tossesInfo.tails}"/></td>
    <td><fmt:formatNumber value="${tossesInfo.pct_tails}"
    type="percent" /></td>
    </tr>
    <tr>
    <td align='center'>
    <input type="submit" name="action" value="Flip
    Coin">
    </td>
    <td></td>
    <td align='center'>
    <input type="submit" name="action" value="Reset">
    </td>
    </tr>
    </table>
    </form>
    <%-- <jsp:useBean id="beanInstanceName" scope="session"
    class="beanPackage.BeanClassName" /> --%>
    <%-- <jsp:getProperty name="beanInstanceName"
    property="propertyName" /> --%>

    </body>
    </html>
    ~~~~~~~~~~~~~~~~~~~~~~~

    And the servlet code is as follows:
    -----------------------
    /*
    * Flip.java
    *
    * Created on April 25, 2005, 6:11 PM
    */

    package org.me.coin;

    import java.io.*;
    import java.net.*;

    import javax.servlet.*;
    import javax.servlet.http.*;

    import java.util.Random;

    /**
    *
    * @author mfernandez
    * @version
    */
    public class Flip extends HttpServlet {

    private Random generator = new Random();

    /** Initializes the servlet.
    */
    public void init(ServletConfig config) throws ServletException {
    super.init(config);

    }

    /** Destroys the servlet.
    */
    public void destroy() {

    }

    /** Processes requests for both HTTP <code>GET</code> and
    <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    HttpSession session = request.getSession();
    TossesBean tossesInfo = (TossesBean)
    session.getAttribute("tossesInfo");
    if ("Reset".equals(request.getParameter("action"))) {
    tossesInfo.reset();
    } else {
    int result = flipCoin();
    if (result == 0) {
    tossesInfo.setHeads(tossesInfo.getHeads() + 1);
    } else {
    tossesInfo.setTails(tossesInfo.getTails() + 1);
    }
    }
    RequestDispatcher rd =
    request.getRequestDispatcher("/index.jsp");
    rd.forward(request, response);
    }

    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    }

    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    }

    /** Returns a short description of the servlet.
    */
    public String getServletInfo() {
    return "Coin Flip";
    }

    private int flipCoin() {
    return Math.abs(generator.nextInt() % 2);
    }
    }
    ----------------------------

    There is also code for a Java Bean but I think the message is getting
    too long now. If it's needed please see the tutorial in
    testwww.netbeans.org/kb/articles/tutorial-webapps-40.html. Anyway, I
    did everything according what's in the tutorial. What am I still
    missing?
    Thanks for any help.
    , Apr 27, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page