0

Its so confusing. Don't have any kind of idea what happend here:

I want to deploy a simple WAR-project. Two HttpServlets, one just forwards the request to another one:

...
String[] selectedOptionsLabels = ...
req.setAttribute("checkedLabels", selectedOptionsLabels);
try {
   req.getRequestDispatcher("/confirmationservlet.do").forward(req, resp);
}
...

When I try to set some values on the form it works great without dispatcher, but when I try this example, my browser can't handle the servlet. It tries to download the file confirmationservlet.do. Confusing.

There seems to be a mapping problem, but I can't figure it out, since the deployment does also work fine.

Do you have an idea?

This is my web.xml (without outer web-app-tag) <--- Only for testing purposes, knowing there are annotations.

<servlet>
    <servlet-name>FormHandlerServlet</servlet-name>
    <servlet-class>
      de.lancom.formhandling.FormHandlerServlet
    </servlet-class>    
</servlet>

<servlet-mapping>
    <servlet-name>FormHandlerServlet</servlet-name>
    <url-pattern>/formhandlerservlet.do</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>ConfirmationServlet</servlet-name>
    <servlet-class>
      de.lancom.formhandling.ConfirmationServlet
    </servlet-class>    
</servlet>

<servlet-mapping>
    <servlet-name>ConfirmationServlet</servlet-name>
    <url-pattern>/confirmationservlet.do</url-pattern>
</servlet-mapping> 

<welcome-file-list>
  <welcome-file>dataentry.html</welcome-file>
</welcome-file-list>
John Rumpel
  • 4,535
  • 5
  • 34
  • 48

1 Answers1

1

Try the following method:

    HttpServletResponse#sendRedirect()

to send a redirect.

     response.sendRedirect("/confirmationservlet.do");
user_CC
  • 4,686
  • 3
  • 20
  • 15
  • Well, let me correct: This worked for me after fixing a really stupid error I made with declaring the response content type. – John Rumpel Mar 26 '13 at 12:11