I run my projetc but after i click Display my DVD Library at index.html error page appear.
HTTP Status 405 - HTTP method GET is not supported by this URL
type Status report
messageHTTP method GET is not supported by this URL
descriptionThe specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
GlassFish Server Open Source Edition 3.0.1
Below is my code...
Please help me..
DVDItem.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.dvd.model;
/**
*
* @author awier
*/
public class DVDItem implements java.io.Serializable {
String title;
String year;
String genre;
public DVDItem(String title, String year, String genre) {
this.title = title;
this.year = year;
this.genre = genre;
}
public String getGenre() {
return genre;
}
public String getTitle() {
return title;
}
public String getYear() {
return year;
}
public void setGenre(String genre) {
this.genre = genre;
}
public void setTitle(String title) {
this.title = title;
}
public void setYear(String year) {
this.year = year;
}
}
ListLibraryServlet.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.dvd.view;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
import com.dvd.model.DVDItem;
/**
*
* @author awier
*/
public class ListLibraryServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request
servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List dvds = new ArrayList();
dvds.add(new DVDItem("Close Encounters of the Third Kind", "1976", "Sci-Fi"));
dvds.add(new DVDItem("Star Wars", "1977", "Sci-Fi"));
dvds.add(new DVDItem("Mission to Mars", "2000", "Sci-Fi"));
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>ListLibrarySerlet</title>");
out.println("<body bgcolor= 'white'>");
out.println("You currently have <b>" + dvds.size()
+ "</b> DVDs in your collection:<br>");
out.println("<table border='0' cellspacing='0' cellpadding='5'>");
out.println("<tr>");
out.println(" <th>TITLE</th>");
out.println(" <th>YEAR</th>");
out.println(" <th>GENRE</th>");
out.println("</tr>");
Iterator it = dvds.iterator();
while (it.hasNext()) {
DVDItem item = (DVDItem) it.next();
out.println("<tr>");
out.println(" <td>" + item.getTitle() + "</th>");
out.println(" <td>" + item.getYear() + "</th>");
out.println(" <td>" + item.getGenre() + "</th>");
out.println("</tr>");
}
out.println("</table>");
out.println("End of list...");
out.println("</body>");
out.println("</html>");
out.close();
}
}
index.html
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>DVD Library Application </h1>
<ul>
<li><a href ='list_library.view'> Display my DVD Library</a></li>
</ul>
</body>
</html>