• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

sendRedirect/RequestDispatcher not working

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem with my servlet that inserts data into the database. I have an HTML form with the POST method that sends the data to the servlet, which in turn inserts the data and redirects to a different form. I have tried using the sendRedirect and RequestDispatcher functions, but it didn't work. When I tried to display an error message in the catch block, it jumps directly to that part. When I remove the redirects and just display a message that the data has been inserted, it works fine. However, as soon as I add the redirect, everything starts to malfunction. I have the necessary libraries since I have already used select and delete queries, and they worked without any issues. What should I do?

Here is my servlet that inserts data into the database:


and here is my JSP page:



 
Sheriff
Posts: 67759
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps it could be useful to include the error that the catch block is showing?
 
maria sirine
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Perhaps it could be useful to include the error that the catch block is showing?



It shows nothing just a white page instaed of the next form where it should be redirected

 
Bear Bibeault
Sheriff
Posts: 67759
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This will be printing the error to your console or to (assuming tomcat). Without it, there's only wild guessing possible.
 
Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic