Gente,
Estou transformando um conjunto de servlets de “bookstore” para páginas .JSP, mas estou encontrando mts problemas ainda…
Coloco abaixo o código JSP q fiz e os seus respectivos erros:
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="javax.servlet.RequestDispatcher" %>
<%@ page import="javax.servlet.ServletException" %>
<%@ page import="javax.servlet.http.HttpServlet" %>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.http.HttpServletResponse" %>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="cart.ShoppingCart" %>
<%@ page import="database.BookDB" %>
<%@ page import="database.BookDetails" %>
<html>
<head><title> Book Catalog </title></head>
// Get the dispatcher; it gets the banner to the user
<% RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(
"/banner");
if (dispatcher != null)
dispatcher.include(request, response);
//Information on the books is from the database through its front end
// Additions to the shopping cart
String bookId = request.getParameter("Add");
if (bookId != null) {
BookDetails book = bookDB.getBookDetails(bookId);
cart.add(bookId, book); %>
<p>
<h3>
<font color="#ff0000">You just added <i><%=book.getTitle()%></i> to your shopping cart.</font>
</h3>
<%}
//Give the option of checking cart or checking out if cart not empty
if (cart.getNumberOfItems() > 0) { %>
<p><strong><a href=<%=response.encodeURL("/bookstore/showcart")%>> Check Shopping Cart</a>&nbsp;&nbsp;&nbsp;
<a href=<%=response.encodeURL("/bookstore/cashier")%>> Buy Your Books</a>
</p></strong>
<%}%>
// Always prompt the user to buy more -- get and show the catalog
<br> &nbsp;<h3>Please choose from our selections:</h3>
<center> <table> <%
Collection c = bookDB.getBooks();
Iterator i = c.iterator();
while (i.hasNext()) {
BookDetails book = (BookDetails)i.next();
bookId = book.getBookId();
//Print out info on each book in its own two rows %>
<tr>
<td bgcolor="#ffffaa">
<a href=<%=response.encodeURL("/bookstore/bookdetails?bookId="+bookId)%>>
<strong><%=book.getTitle()%>&nbsp; </strong>
</a>
</td>
<td bgcolor="#ffffaa" rowspan=2>
<%=Currency.format(book.getPrice(), request.getLocale())%>&nbsp;
</td>
<td bgcolor="#ffffaa" rowspan=2>
<a href=<%=response.encodeURL("/bookstore/catalog?Add="+bookId)%>> &nbsp; Add to Cart &nbsp;
</a>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
&nbsp; &nbsp; by <em><%=book.getFirstName()%> <%=book.getSurname()%></em>
</td>
</tr>
<%}%>
</table></center>
</body>
</html>
<% out.close();
}
public String getServletInfo() {
return "The Catalog servlet adds books to the user's " +
"shopping cart and prints the catalog.";
}
}%>
E agora seus erros:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
No Java compiler was found to compile the generated source for the JSP.
This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK
to the common/lib directory of the Tomcat server, followed by a Tomcat restart.
If using an alternate Java compiler, please check its installation and access path.
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
Peço desculpas a vcs se colokei coisas desnecessárias neste topic mas iniciante né, vcs sabem como é…
Desde já agradeço,
[]'s
Beto.
