Call a Servlet from a jsp

Can we call a servlet from a JSP, come back and display the response data we get from the servlet in the same JSP? Is it possible to do that?

Basically, I have a pop up in which the user gives some input. I pass this to the servlet and the servlet gives me an acknowledgement number. I would like to display this acknowledgement number in the same pop up.

In the meantime, during which the servlet gives the response, I can display an hour glass in the pop up. Is this possible?

Someone please help me with an example please.

Answers


Option 1 You can submit form in your popup jsp and then forward to the same JSP from servlet. Option 2 You can use ajax and call servlet and then send response (e.g. JSON) back from servlet and update what you need using javascript, jquery.


Yes we can call servlet from jsp.

To call servlet from jsp use,

<form action="../Your_servlet_name_in_web.xml_file">

And to call JSP from servlet use,

response.sendRedirect("Your_JSP_NAME.jsp");

For calling servlet from jsp

Hope this will help you.


Need Your Help

Express with Advanced Services, can't create Full Text Index

full-text-search sql-server-express sql-server-2012

I have installed SQL Server 2012 Express Edition Advanced Services which states that it includes Full-text indexing. Here is a link that states this:

How to remove Unwanted ads on my drupal

drupal-7 ads

I see some ads on my drupal website. No idea where they came from but I want to get rid of them. Any help appreciated

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.