For a code I am working on I'm using servlets with jsp. In the servlets I have doPost and doGet with certain servlets that I want to get something on the server or to add it. In the jsp I have the method of post and get in the form. Each time I run my code I cannot get anything that is on the server, i get an error saying http get method not supported on the server same with post. Can someone look at the code and see if there is anything missing. I have been looking at this for many times and I cannot get it to work. Here is some of my servlets and jsps:
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class AddTagServlet extends HttpServlet{ private static final long serialVersionUID = 1L; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean isSuccess= false; String isbn13 = request.getParameter("isbn13"); Tag tag = new Tag(); tag.setIsbn13(isbn13); tag.settag(request.getParameter("tag")); TagDAO tagdao = DAOUtilities.getTagDAO(); isSuccess = tagdao.addtag(tag); if(isSuccess){ request.getSession().setAttribute("message", "Tag successfully added"); request.getSession().setAttribute("messageClass", "alert-success"); response.sendRedirect(request.getContextPath() + "/ViewBookDetails?isbn13=" + isbn13); } else { request.getSession().setAttribute("message", "There was a problem updating this tag"); request.getSession().setAttribute("messageClass", "alert-danger"); request.getRequestDispatcher("bookDetails.jsp").forward(request, response); } } } public class BookPublishingServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Grab the list of Books from the Database BookDAO dao = DAOUtilities.getBookDAO(); List<Book> bookList = dao.getAllBooks(); // Grab the list of Book tags from the Database TagDAO tagdao = DAOUtilities.getTagDAO(); List<Tag> tagList = tagdao.getAllTags(); // Populate the list into a variable that will be stored in the session request.getSession().setAttribute("books", bookList); request.getSession().setAttribute("tags", tagList); request.getRequestDispatcher("bookPublishingHome.jsp").forward(request, response); } } <section class="success"> <div class="container"> <h1><small>Add Tag</small></h1> <form action="AddTag" method="post" class="form-horizontal"> <input type="hidden" class="form-control" id="isbn13" name="isbn13" placeholder="ISBN 13" required="required" value="${book.isbn13}" /> <div class="form-group"> <label for="tag" class="col-sm-4 control-label">Tag</label> <div class="col-sm-5"> <input type="text" class="form-control" id="tag" name="tag" placeholder="Tag" required="required" /> </div> </div> <div class="form-group"> <div id="popover-bookpub-addtag" class="col-sm-offset-4 col-sm-1"> <button type="submit" class="btn btn-info">Add Tag</button> </div> </div> </form> </div> <td><c:out value="${book.isbn13}" /></td> <td><c:out value="${book.title}" /></td> <td><c:out value="${book.author}" /></td> <td><c:out value="${book.publishDate}" /></td> <td><fmt:formatNumber value="${book.price }" type="CURRENCY"/></td> <td><form action="DownloadBook" method="get"> <input type="hidden" name="isbn13" value="${book.isbn13}"> <button class="btn btn-success">Download</button> </form></td>