SHE SHE - 1 year ago 98
Java Question

JSP got http error while refreshing the page

I went through a basic tutorial about JSP and JDBC and wrote some java code in eclipse and try deploying using JSP

Here is the JSP code, basically it list all the rows (name and price) in the database and you can submit name and price by pressing the button (not implemented yet) :

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
import ="edu.neu.cs5200.s3.onlineide.applications.*, java.util.*"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="css/bootstrap.css" rel="stylesheet"/>
applicationsDAO dao = new applicationsDAO();
String action=request.getParameter("action");
String name=request.getParameter("name");
String price=request.getParameter("price");
String id=request.getParameter("id");

double priceD=Double.parseDouble(price);
Application app=new Application(name, priceD);

List<Application> applications=dao.selectAll();
<form action="application.jsp">

<table class="table">
<td><input name="name" class="form-control"/></td>
<td><input name="price" class="form-control"/></td>
<button class="btn" name="action" value="create">


<% for (Application app: applications){
%> <tr>
<td><%=app.getName() %></td>

It originally looks like this:
enter image description here

However, when I enter "Checkers" and "599" press the "add" button, it looks like this:
enter image description here

Based on the tutorial, since I have not implemented the button yet, it should looks like the original page with the only change that the url changes to http://localhost:8080/OnlineIDE/application.jsp?name=Checkers&price=5.99&action=create when I enter "Checkers" and "5.99" but I got a http error. Why is that?

Answer Source

The original was for applications.jsp, but later your link is to application.jsp. You forgot the s.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download