Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Servlet 404 issues
    primarykey
    data
    text
    <p>I am working on a simple program redirection by making some calls to a servlet. However, for some reason, I am continuously getting a 404 error every time I try to construct the code in this particular project build.</p> <p>It may be of note that I am building this project in Eclipse and am using Apache Tomcat.</p> <p>here is my coding....</p> <p>HTML first:</p> <p>To save some aggrivation, this is the particular snippet on where the problems arise. My connection to the MySQL database along with the database reads are operating perfectly fine.</p> <pre><code>&lt;form action="objectServer" method="get"&gt; &lt;select name="choice"&gt; &lt;% while (rs.next()){ %&gt; &lt;option value="&lt;%=rs.getString(2) %&gt;"&gt;&lt;%=rs.getString(2) %&gt;&lt;/option&gt; &lt;% } MysqlConnection.close(connect); %&gt; &lt;/select&gt; &lt;br /&gt; &lt;input type="submit" value="View the Descrition!" /&gt; &lt;/form&gt; </code></pre> <p>Java code:</p> <p>The first is a simple java class that validates whether an item has been selected and acts to help redirect.</p> <pre><code>package com.program.service; public class Service { public boolean redirect(String selected){ if( (selected == null) || (selected == "") ){ return false; } else { return true; } } } </code></pre> <p>And finally, the servlet itself. </p> <pre><code>package com.program.servlet; 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; import com.wines.service.Service; @WebServlet("/objectServer") public class InfoServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String selected = request.getParameter("choice"); Service service = new Service(); boolean redirector = service.redirect(selected); if(redirector){ response.sendRedirect("next_page.jsp"); } else { response.sendRedirect("this_page.jsp"); } } } </code></pre> <p>As one can see, this is a REALLY simple program that should be redirecting to the next page, but for some reason I am missing something that I just cannot see at this moment. I don't don't know whether it's an issue with my coding, my server, or something else I could have missed. As a note, the web.xml has not been programmed in this particular application as of yet.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload