• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

user registration via Servlet/JSP/JDBC

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have created a user registration JSP page accepting username, password & address. On Clicking submit flow navigates to the servlet.

Servlet code




Guys I want if the table update is successful, user is navigated to a new jsp page with this message " Welcome 'Username'". Please help me out, how do I do that ???
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can either forward (internally) to the desired page using RequestDispatcher.forward(), or send a redirect response to the browser using HttpServletResponse.sendRedirect(). Using either of these (one more appropriate then the other) you can greet your user with a welcome message, and depending on the intent of the user, you can start restoring a backup of your database.
 
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ResultSet rs= stmt.executeQuery(queryString);


rs.next() will give you true if it inserts. based on this condition you can forward to any page you like as @Jelle Klap said.
and you can set a message in session attribute or in query string, and you can get that message in forwarded page. In your case set username in session or query string
eg:
 
shivang sarawagi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever I am using session.setAttribute(); do I always have to first create a session by

HttpSession session = request.getSession(); ???
 
Sheriff
Posts: 67746
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
No, that doesn't necessarily create a session, just obtains a reference to it.
reply
    Bookmark Topic Watch Topic
  • New Topic