• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp form action issue  RSS feed

 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I develop a calculator according to the MVC model.
I use the dopost method in my servlet, everything works well but my result is directed to another HTML or jsp page, my problem is this:

Here i the result is redirected to a blank page or i write in it!
While my shema is on page jsp: calculator.jsp

Here I have a 404 error that appears

How can I stay on the current page without being redirected?
I would like to stay on the page of my calculator to be able to display the result in my textbox.
Regards
Philippe
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66260
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either have the servlet redirect back to the same page after it does its work, or call the servlet using Ajax from the original page so that there is no page transition at all.
 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Either have the servlet redirect back to the same page after it does its work, or call the servlet using Ajax from the original page so that there is no page transition at all.


i'm french and i'm lost into the documention, can you explain please !
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saying what Bear said in more words:

You have two options for what you want to accomplish.

Option 1
Calculator JSP submits the form to your servlet like it does now. It passes all the selected fields to the servlet. The servlet does its work. Then when the servlet is done, it has to direct somewhere. So you have it redirect to Calculator JSP and set the fields to the original values.

Option 2
Don't submit the form at all. Instead use an asynchronous call (AJAX) to call the servlet. Then the servlet just returns the value and you use JavaScript to update the JSP with the new value.
 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Saying what Bear said in more words:

You have two options for what you want to accomplish.

Option 1
Calculator JSP submits the form to your servlet like it does now. It passes all the selected fields to the servlet. The servlet does its work. Then when the servlet is done, it has to direct somewhere. So you have it redirect to Calculator JSP and set the fields to the original values.


i choise option 1, can i add a text and stay to the form calculator JSP (my error is who can i stay to the form) without use a code lije AJAX so difficulte , it's possible or not ?

Regards
Philippe
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't stay on the JSP without using AJAX. Option 1 isn't to stay on the page. It's to re-render the page after submitting.

Neither of these options is "hard". Both take learning.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!