facebook

JSP codes seems not executed correctly

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #235852 Reply

    tllcll
    Member

    Hi,

    I would like to check with you how JSP codes residing in js function works.

    How can I get the 2nd select stmt executed based on the values retrieve from 1st select statement and the conditions pass in to this js function

    How can I get the select statement to execute only when a condition is met.

    The following is the codes. It is not executing the 2nd select statement. when I didnt put in the 2nd select stmt, i manage to execute codes in that portion

    script
    ====
    function test(obj, obj2) {
    <%
    sql_query = “SELECT a1, a2 , a3, a4, a5 “+
    ” FROM table_a “;
    try {
    rset = db.execSQL(sql_query);
    }
    catch(SQLException e){
    System.err.println (“Error in query ” +e);
    }
    %>

    var po_ln_fnd = false

    <% while (rset.next()) {
    j_a1 = rset.getString(“a1”);
    j_a2 = rset.getString(“a2”);
    j_a3 = rset.getString(“a3”);

    %>

    if ((eval(obj2.value)== ‘<%=j_a1%>’)) {
    if ((obj.value == ‘<%=j_a2%>’) ) {
    <% j_a4 = rset.getString(“a4”);
    j_a5 = rset.getString(“a5”);

    sql_query = “SELECT b2, b3, b4 “+
    ” FROM table_b “+
    ” WHERE b1 = ‘”+j_a3+”‘ “;
    try {
    rset = db.execSQL(sql_query);
    }
    catch (SQLException e) {
    System.err.println(“Error in query ” +e);
    }
    while (rset.next()) {
    j_b2 = rset.getString(“j_b2”);
    j_b3 = rset.getString(“j_b3”);
    j_b4 = rset.getString(“j_b4”);
    }
    %>
    }
    }
    <%}>
    }

    #235890 Reply

    Riyad Kalla
    Member

    I don’t know how this could work, JSP is a server-side technology, JS is a client side technology. They execute at totally separate times and under seperate conditions…

    #235976 Reply

    tllcll
    Member

    Since that the case, is there any alternative that I can use to perform the operation & how can I get it done.

    Thks

    #235977 Reply

    Riyad Kalla
    Member

    I think what you want is AJAX, in your case, your JS function would make a call to your server to perform the query:
    http://myserver.com/servlet/search?term=java

    Then your server would return XML-formatted results back to your JS code, which would parse it and update your screen.

    #235983 Reply

    tllcll
    Member

    Hi

    I would like to find out from you what is AJAX and the http address given can’t be accessed : Non-Existent domain

    #235987 Reply

    Riyad Kalla
    Member

    AJAX is a new method of development that is becomming very popular for web applications. To see it in action take a look at http://maps.google.com

    It is a design idea, not a library. The way it works is you use Javascript to make server calls on the fly, and then update your web page using Javascript with the results without ever needing to reload the page. Because AJAX is a design idea and not a library, there are many different ways to employ it. It’s a lot like saying “Use MVC when developing in Java”, it’s a *way* to code your pages.

    Read this tutorial to get started, to get the idea of how it works: http://today.java.net/pub/a/today/2005/08/25/dwr.html

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: JSP codes seems not executed correctly

You must be logged in to post in the forum log in