Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

[problems running this code

843838Jun 20 2007 — edited Jun 21 2007
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2007
Added on Jun 20 2007
2 comments
110 views