This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes built a program that can directly run in the same page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "built a program that can directly run in the same page" Watch "built a program that can directly run in the same page" New topic
Author

built a program that can directly run in the same page

albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
i want to built a program that will contain 2 combo box for user to select and some empty field is for retrieve the data from the database. what i want to do is after the user select the value from the combo box, the page will direct retrieve the data from the database and display on the same screen.what i want is all of this process will be done in one page only.how i can perform like this beside using the AJAX??

thank you

regards,
albert
[ April 07, 2006: Message edited by: Bear Bibeault ]

JAVA the only can called technology
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

What has become known as Ajax, either through the use of XMLHttpRequest or the use of a hidden iframe, is the only means (without resorting to Applets) to make such a thing possible.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
that mean i have to use AJAX.
i want to make sure something, if i want to using AJAX i need to write a javascript code in the relevant page and a server script right?
i already write the javascript part in my program but now i stuck in the server script to ask the server to pass back the value. that because the combo box value can be retrieve using DOM by javascript, i need to get the value from the server script from there change to java then pass back the value to the client page to do the retrieving database process which is in client page. is it my concept is on the track???
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
in order to use AJAX in jsp, is it i need to use the dwr api???
i found 1 artical on internet which is " ask to download the API, is it true???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Originally posted by albert sie:
in order to use AJAX in jsp, is it i need to use the dwr api?


No. Whether your page is generated via JSP or anything else is completely immaterial. Once the page gets to the browser it's just an HTML page like any other.
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
after the client make the request from the first page, is it i need to write a script file to ask the server send back the data that the client request. In my plan is for example A.jsp page is the first page. in A.jsp contain 2 combo box and below the combo box is the empty field that i create using the table to align, for example the field will in this code: <td>Name</td><td>:<%=name%></td> the name will retrieve from the database. What i want is after user select from the combo box the page will make request from the server then send back the combo box value then the A.jsp page will depend on the value return to retrieve the database. i know how to make request but i not sure is how the server will send back the value to the A.jsp??
can anyone give me concept of this. thank you for the help that pour to me. thank you

regards,
albert
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
anybody can give me the concept on how to do. i try many way but still cannot get. i try hard to get that but i can't. can anyone give me some help and guidance
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Originally posted by albert sie:
how the server will send back the value to the A.jsp??
It doesn't. You need to get that concept out of your head.

Remember that your JSP code is executed on the server. It produces some HTML, which can include Javascript, and sends it to the client. At that point, as far as you are concerned, the JSP page no longer exists. It is finished.

Then the browser gets that HTML and renders it. Remember that this is not the JSP page it gets. That JSP page is dead. The browser gets some HTML and renders it. Any Javascript in that HTML will be run whenever the HTML says so. Therefore, when learning about AJAX you only need to understand how it fits into HTML.

There are plenty of examples of AJAX floating about on the Internet. People have even written entire books about the subject. You have already tracked down some examples, so look for more.
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
i know the different between the application that using AJAX and without AJAX. The normal web application architecture is the after the user submit, the page will go through the server and the server will get the second page and send back to the client and the client will using "request.getParameter" to get the value, this is the normal web application. Since the ajax can request the value from the server without reload the page, so for the ajax architecture is when the client make request, it will go through the ajax engine first and the AJAX will make the request to the server and the server also will pass back the value to the client through the ajax machine. what i need to do is i also want to do the machanism of decrease the time of reloading of the pages.is it when i submit the page i should point back to the same page so that my value will be past back to the same page???

correct me if i wrong? and where i can get more resources about to use ajax with the jsp and java???


thank you...

albert
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you not read the links I gave to you in your other topic that is covering the smae exact thing?

http://www.coderanch.com/t/117743/HTML-JavaScript/ask-pass-value

In the are working examples with Java and Ajax for a double combo.

Eric
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
Oops i will go through it now. and 1 thing i want to know is for my situation is it i needed the server site script to get the value from 1st page and pass back to first page???
Anantha Reddy.N
Greenhorn

Joined: Mar 21, 2006
Posts: 11
Originally posted by albert sie:
after the client make the request from the first page, is it i need to write a script file to ask the server send back the data that the client request. In my plan is for example A.jsp page is the first page. in A.jsp contain 2 combo box and below the combo box is the empty field that i create using the table to align, for example the field will in this code: <td>Name</td><td>:<%=name%></td> the name will retrieve from the database. What i want is after user select from the combo box the page will make request from the server then send back the combo box value then the A.jsp page will depend on the value return to retrieve the database. i know how to make request but i not sure is how the server will send back the value to the A.jsp??
can anyone give me concept of this. thank you for the help that pour to me. thank you

regards,
albert




your first page is a.jsp right? key in the fallowing code it may help u out in ur problem.

<--a.jsp-->
java.sql.ResulSet result=session.getAttribute("result");

if(result!=null)
{
//write the code here to display result object in jsp
<table><tr><td>reult.getString(1)</td></tr></table>
}
else
{
//write the code here to display 2 combobox
<form action="./actionServlet" method="post">
<select combo1>
<select combo2>
</form>
}


Regards
Ananth


Anantha Reddy.N
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
i get it ups now. thanks everyone here for giving me so much suggestion and help

thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: built a program that can directly run in the same page