Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

HTTP Status 405 - HTTP method GET is not supported by this URL

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
 
Bear Bibeault
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where, in your servlet, do you override doGet()?
 
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ListLibraryServlet should override the doGet method.
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You created a method named processRequest instead you need a method named doGet and/or doPost.

If you want, there is a link in my signature that might help you with this doubts.
 
anis Farim
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks everyone. i get it....
 
anis Farim
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Bear Bibeault....
i am new in this forum... i not do my mistake again... really sorry

 
Bear Bibeault
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no need to apologize. The guideline is there to help You get better answers.
 
anis Farim
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.. tq...
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!