Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get results into same jsp

 
ramesh poorella
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...

am entering some values and submitting form . then after that how to get result in same page.... i mean request must go servlet and proceed some criteria and after that the processed results came to same jsp with out forward another page. if using redirect to same page the page will printing same as before but not getting results..

how it will be done? help me
 
N Sahni
Ranch Hand
Posts: 55
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In order to get results in same page from server, you need to make an AJAX call to the servlet, get the results and render it using java script.
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you can use JSTL tag import.
For example:
1) make you jsp form for search criteria. (page1)
2) build a jsp page for result (page2) and import the page1 inside page2 with jstl tag import.
TIP: In the form action of you page1 form call to page2.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64848
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Ajax approach is far superior. In fact, I don't even see how using the JSTL import approach as described can possibly work.
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The Ajax approach is far superior. In fact, I don't even see how using the JSTL import approach as described can possibly work.


I did that!!
I will try to explain my case:

I did a search.jsp, this had one field input for criteria search.
Then i did create a jsp for result. This result.jsp ask for parameters, is to say, i must to pass parameters from search.jsp o result.jsp.
Therefore:
search.jsp submit a value (parameter) . In the form action property call to result.jsp page and pass the parameter. In my result.jsp page i pass the parameter to a method than make a query. Then the result in showed in a html table in my result.jsp page.

In other words;
(in result.jsp)
1)in the first block request the value (parameter) if the parameter is null then not display data, if the parameter is diferent to null build the query and disply the data below
2) in the second block include the page <c:import url="search.jsp"/>
3) in the third block of my result.jsp page show the data in a html table.


I hope you understand my explanation, sorry for my english grammar.

And Yes, you are right about Ajax, I am using AJAX and Jquery lately and it is so nice and pretty for do similar things.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic