aspose file tools*
The moose likes Servlets and the fly likes HTTP Status 405 - HTTP method GET is not supported by this URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP Status 405 - HTTP method GET is not supported by this URL" Watch "HTTP Status 405 - HTTP method GET is not supported by this URL" New topic
Author

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

anis Farim
Greenhorn

Joined: Oct 09, 2010
Posts: 5
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>

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61227
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61227
    
  66

Where, in your servlet, do you override doGet()?
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

ListLibraryServlet should override the doGet method.
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

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.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
anis Farim
Greenhorn

Joined: Oct 09, 2010
Posts: 5
thanks everyone. i get it....
anis Farim
Greenhorn

Joined: Oct 09, 2010
Posts: 5
Sorry Bear Bibeault....
i am new in this forum... i not do my mistake again... really sorry

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61227
    
  66

There's no need to apologize. The guideline is there to help You get better answers.
anis Farim
Greenhorn

Joined: Oct 09, 2010
Posts: 5
ok.. tq...
 
 
subject: HTTP Status 405 - HTTP method GET is not supported by this URL