wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP database issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP database issue" Watch "JSP database issue" New topic
Author

JSP database issue

Jai D Parmar
Greenhorn

Joined: Jan 23, 2006
Posts: 3
Hello all,
I am trying to do a simple thing i think, but cant think of a way of doing it.

I have a popup that is a JSP page.
This jsp page contains input fields, these input fields are used to query a back end database.

I have created a bean that makes the databse query by setting the arguments.

The problem is that these results must be shown on the same page.
any ideas on how to go about doing this?

Thanks
Jai
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Originally posted by Jai D Parmar:
The problem is that these results must be shown on the same page.
Well, no, that's a complicated thing. The simple thing would be that the popup window contains a page (HTML or JSP) with the input fields and a Submit button, and clicking the button causes a second page to appear complete with database information. Why can't you do that?

If the requirement is only that the second page must also appear in the popup window, that's the default behaviour anyway.
Sujith Kanaparthi
Ranch Hand

Joined: Sep 04, 2005
Posts: 45
One way is : when you submit the values, pass those to another jsp which uses the bean to query the the database to fetch the results.Store this result in a session and redirect it to the first jsp.

Another way :
A sample Test.jsp can be as coded below

<%if(request.getParameter("initial")==null){%>
<form name="frm" method="post" action="Test.jsp" >
<input type="text" name="qry" value="">
<input type="submit" name="Query">
<input type="hidden" name="initial" value="1">
</form>
<%}else{%>
//Code to query the DB and fetch the result
// display the result here
<%}%>

Regards,
Sujith
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JSP database issue