i have an html page with a hyperlink. when i click on it. it should move on to other html page and display the records of a database in that second html page.

so i'll write a jsp (writing jdbc code in it)to retrieve the records and now since i redirect to a second html page. how do i make the records displayed on the redirected page?

Apart form Peter's suggestion I will like to add something.

First if you are reading the data in one jsp why aren't you displaying them in the jsp you are reading them? Or why don't you read the data at the jsp that the link takes you?

It makes no sense to read data in one jsp and then click a link in order to take you to another and display the data there.

One thought is that you probably read the request in the 1st jsp: String s = request.getParameter("something") that came from a "submit" button, and you don't know how to send the request to another jsp using a link.

If that is the case then: <a href="second.jsp?something=5&another=test">Click here</a> or

String s1 = "5";
String s2 = "test"
<a href="second.jsp?something=<%= s1%>&another=<%= s2%>">Click here</a>

At the other jsp you can do:

String s1 = request.getParameter("something"); // 5
String s2 = request.getParameter("another"); // test

Of course you must never connect to a database inside a jsp or do anything else apart from displaying data or sending data other JSPs or servlets.

So in your case the link should take you to a servlet, then read the database, then redirect using Peter's example to the jsp you want.

i want to display the results in a webpage which is one of the frames of a page. so. if i dont redirect,how can i do that?
if i want to display in a webpage, i can simply write everything in
out.println("<html>...................."); but in this i dont think i can do that.

This is part of an example:

Navigation frame
How to make a navigation frame. The navigation frame contains a list of links with the second frame as the target. The file called "tryhtml_contents.htm" contains three links. The source code of the links:
<a href ="frame_a.htm" target ="showframe">Frame a</a><br>
<a href ="frame_b.htm" target ="showframe">Frame b</a><br>
<a href ="frame_c.htm" target ="showframe">Frame c</a>
The second frame will show the linked document.

Look at it at this page and click the link: Navigation frame for further details.

When you click the link: Frame a the new page will not open in a new window but only at the target which will be the frame you specify. Don't forget to give a "name" to each of your frames. Use the "name" attribute as shown at the example, at the link Navigation frame.

deepak_8917 - you should be also aware that use of frames is discouraged by W3C and their used in new HTML 5.0 is minimized. You better to think of some other idea of presenting your data.

hmm. it seems u have not understood my problem.
let me be more clear..
i have a database containing set of questions. i want the html page to display those records so that an admin selects a question from it which he wants to remove from database.
so i thought i would display the list of the questions in one frame and textfield to enter the question number to be deleted in a second frame and a submit button there. all the deletion process (like taking the question number and deleting) can be handled by other jsp

SO, when i click on a link like "delete question" from a home page it should move to a page containing two frames and the first page should be able to present the database contents.
writing the secong frame page is not a problem. but how to present the database contents on first frame page while loading..

tell me where i am not clear so i'll try to be more clear.
i sincerely thank for your effort in solving my problem.

Why don't you put everything in one jsp. When the user clicks Submit go to a servlet and delete the row.
Then you can either read again the data from the the database and display them or
You can have the previous data in List. Then whenever you submit or display the data you can have the List sent into the request with the "request.setAtttribute". If the delete is successful remove that data from the List and send it again at the request to be displayed

though the solution was not totally clear for my problem
i somehow managed with out using frames.
javaaddict's last reply was also helpful.
thanks..

This article has been dead for over six months. Start a new discussion instead.