Servlet to JSP issues

Hi, I am new to web development and am working on a web application that will use servlets and JSPs and I created both my servlet and my JSP but I am having a hard time getting the servlet to forward the request to the JSP.

In my main page, there is a form that uses a get method and the action is pointed to my servlet (SelectSupportUnit.do):
"<form method="get" action="SelectSupportUnit.do">

And in my servlet, it forwards the results from my JDBC Query to a JSP:
"request.setAttribute("suppUnitList", suppUnitList);
RequestDispatcher view = request.getRequestDispatcher("QueryResults.jsp");
view.forward(request, response);"

And in my web.xml file it declares the JSP (this is what it says to do in the Head First Servlets and JSPs book when forwarding a request from your servlet to a JSP):
<servlet>
<servlet-name>SelectSupportUnit</servlet-name>
<jsp-file>/QueryResults.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>SelectSupportUnit</servlet-name>
<url-pattern>/QueryResults.jsp</url-pattern>
</servlet-mapping>

When I run this (using Eclipse IDE and Tomcat v7 container) it is giving me HTTP status 404. And says it cannot find my servlet (SelectSupportUnit.do).

That would make it appear as if in the <form> element that calls the servlet, you should call the JSP, but if I do this won't it bypass the servlet?

In my main page, there is a form that uses a get method and the action is pointed to my servlet (SelectSupportUnit.do):
"<form method="get" action="SelectSupportUnit.do">

Two things:

What's with the .do suffix? That's an antiquated convention from Struts 1 days that just makes your stuff look dated. I'd drop it in favor of more modern mappings.

Your action is missing the context path. The action should either be action="${pageContext.request.contextPath}/SelectSupportUnit.do", or created as the result of the <c:url> JSTL action (which will automatically inserts the context path).

And in my web.xml file it declares the JSP

Why? Superfluous and unnecessary. Don't bother.

When I run this (using Eclipse IDE and Tomcat v7 container) it is giving me HTTP status 404. And says it cannot find my servlet (SelectSupportUnit.do).

That has nothing to do with the forwarding. It's because of the poorly formed action URL.

That would make it appear as if in the <form> element that calls the servlet, you should call the JSP, but if I do this won't it bypass the servlet?

You never directly address a JSP. Always address its servlet controller.

Well after that change to my action attribute definitely helped! It is recognizing that it should be sending it to a JSP. But now I am getting an HTTP status 404 for the JSP. Do I need to declare the fully qualified path in my servlet to the JSP?

And could you give me a little more detail on the <c:url> element. I know it goes into my JSP and it has something to do with URL encoding. But I am unsure how to use it in this instance.

This is weird, when I posted this thread on Friday, it was working just fine (except I was getting a Null Pointer Exception cause my servlet is incorrect). But today when I came in and loaded it up I am getting this error:
/Disaster_Recovery_Web_Page/$%7BPageContext.request.contextPath%7D/SelectSupportUnit

I looked around and I found a forum on this site with that error and I went through it to see if I was having the same problem (forum thread found here. And at the end of that forum his problem was he needed to rename his JSP to .jsp as opposed to .html. However, mine is already named .jsp.

And as far as my servlet executing; it was executing, then I tried to forward the request to a JSP and it was giving me issues which is why I started this thread. Then Bear recommended changing my action item, so I did, and it worked just fine on Friday (besides getting a Null Pointer Exception) and now when I run the page and click on my button that invokes the servlet it is giving me this error:
/Disaster_Recovery_Web_Page/$%7BpageContext.request.contextPath%7D/SelectSupportUnit.do

I am using Tomcat 7.0.3 as my container, and I am using Eclipse Juno as my IDE. I am using JSP 2.0.

When I run my main page--called index.html--it loads that page just fine. I have a button on that page that is invokes the servlet SelectSupportUnit.java. It is that button that has the <form> element I mentioned earlier.
When I click on that button, I get a new window that has this error:
HTTP Status 404 - /Disaster_Recovery_Web_Page/$%7BpageContext.request.contextPath%7D/SelectSupportUnit.do

Correct. It was in the same web app. I didn't run the html file and connect it to the JSP with the ${3+4}. I just ran that JSP.

And when I placed that fragment in my JSP it gave me the same error when I tried to access it through the index.html. But it gave me HTTP status 404 when I just ran it. But that is because it cannot be accessed by the client directly because it is placed inside of my WEB-INF folder.

Bear, you mentioned earlier the <c:url> tag which would automatically create the context path for me. Would that be a better solution than doing ${pageContext.request.ContextPath}/SelectSupportUnit.do?

or created as the result of the <c:url> JSTL action (which will automatically inserts the context path).

Since I was accessing the servlet from my index.html sheet my action item looks like this:
<form target="_blank" method="get" action="SelectSupportUnit.do">
That invokes the servlet, which runs SQL commands on a database, makes the ResultSet from the query a Result object and then forwards that Result object to a JSP which displays the query information in a JSP.

One followup: it is never a good idea to send the result set to the the JSP. That exposes too much DB-specific info to the front end, and causes the result set and associated DB resources to be held open for far too long.

Rather, copy the result set's info to regular Java collections (which to use depends upon the nature of the data) and/or beans, and close all the DB resources ASAP. Then pass the collections/beans to the front end where JSTL and EL (never scriptlets) in the JSP can use them.