hello all. i am trying to run a simple example which consist of a servlet, jsp and a java file. i am using eclipse. For some reason when i try to run my jsp file in eclipse the output in the browser displays that
type Status report
message /ProductServlet/ex.jsp
description The requested resource (/ProductServlet/ex.jsp) is not available.
http://localhost:8080/chapter4/ProductServlet/ex.jsp
I am running in eclipse builtin browser.
here is my simple easy looking Product code with getter and setter methods
Product.java
package chapter5;
public class Product {
private String name = null;
private double price = 0.0d;
public String getName( ) {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice( ) {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
Here is my ProductServlet
package chapter5;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;
public class ProductServlet extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
Product product = new Product( );
product.setName("Hyperwidget");
product.setPrice(599.99d);
request.setAttribute("product", product);
request.getRequestDispatcher("chapter4/ex.jsp")
.forward(request, response);
}
}
and here is my ex.jsp
<html>
<body>
<%
java.util.Date theDate = new java.util.Date( );
%>
<% if (theDate.getHours( ) < 12) { %>
Good morning,
<% } else { %>
Good afternoon,
<% } %>
visitor. It is now <%= theDate.toString( ) %>
<br>
Is three greater than four? That's ${3 > 4}.
The sum is ${3+4}, though.
<h1>${product.name}</h1>
Price: $${product.price}
</body>
</html>
Can someone point out what am i doing wrong?