Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirect to another page after inserting

 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, currently I am doing on insert products into the database.
The insert form, I am making use of hashtable in multi part form so that I can upload images as well as insery data into the database.

I can insert thr details as well as the images into database. But I cannot redirect to another page that have like :Successfully inserted

Can you guys help me on it?

Thanks for your help

Appreciate it all these while
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose you are in a servlet.



That's about it. Note that the file name starts from the web app context root.
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

What happen if I am using hashtable in jsp page.


 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can happily do that in a scriptlet.

Whatever comes between <% %> is plain Java. After all the JSP is translated into a Servlet.

Best practice however is to totally abstain from using scriptlets, declarations and the like.

Your servlet is the place to do the processing, the JSP is for displaying what has been processed. So generate your HashMap in the servlet, set it as a request parameter, and access the values in the JSP. That's the way to go...
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see i see.
Which mean we have to implement the hashtable inside the servlet?


Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, as you should have no Java code in your JSPs.
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see I see. Do you guys have any exmaples of impleenting hashtable inside servlets that allow us to upload image as well as date into the database.

Thanks.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really know how a HashMap and a database upload go together.

Could you give a quick example ?
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure

This is the code that I make use of



Thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic