Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

passing result of a datanase query to javscript

843841Nov 5 2004 — edited Nov 5 2004
Hello ,

I am a newbie to servelt technology...so please bear with me...

I have a servlet in which I have to query the database twice ( for some development specific reason) . I the second query I want the just one value:
Stirng query = Select vpath from video v where v.vname=' " videoName"'; (videoName is obtained by request.getParameter )
ResultSet res =myHandler.executeQuery(query); (myHandler is my database handle)
String url = res.getString(1);

I want to be able to pass this value(url) to some javascript code written in the servlet itself :

//writing the jsp file
out.println("<%@ page contentType='text/html; charset=iso-8859-1' language='java' import='java.io.*, java.util.* errorPage=''%>");
out.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'><title>View Recorded Video</title></head>");

//the <SCRIPT> and its content
out.println("<script language='javascript'>");

out.println("var urlname = '"+ url +"'");
//out.println("function OpenTranscript() { var popWin1 = window.open(urlname, 'ViewTranscript', 'height=200,width=360'); }");
out.println("</script>");
where the openTranscript () is called when the user clicks a button.

WHen I write this code I cannot see anything in my jsp page (i have some other buttons and textboxes there) I am doing something wrong? Can a servlet handle multiple database queries?
This code may be entirely wrong....but like i said I am a newbie.
How do I pass the url (returned from db) to the javascript?
thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2004
Added on Nov 5 2004
1 comment
93 views