Note that there are some explanatory texts on larger screens.

plurals
  1. POFunction With Multiple Values JavaScript+JSP+Servlet
    text
    copied!<p>I have a project in Java with JSP+JavaScript+Servlets, with a function in JavaScript to find some record in my database. When this record is found, my function returns some value, and when it's not, my function returns a message. Now I need another function to return several fields from my database, and I don't know who. I'm not very familiar with JavaScript and JSP.<br> EDIT: I did some changes </p> <p>This is part from my JSP code: <br></p> <pre><code> &lt;% HashMap row = new HashMap(); %&gt; &lt;tr&gt; &lt;td&gt; &lt;input type='text' id="noeco" name="noeco" size=5 maxlength=5 onkeyup="find_noeco_s(noeco,row);"&gt; &lt;span name="exists" id="exists" readonly="readonly" style="width: 200px" value='{row.get("exists")}'&gt;&lt;/span&gt;&lt;/input&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input type='text' id="matric" name="matric" readonly="readonly" value="{row.get('matri')}"&gt;&lt;/input&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input type='text' id="marca" name="marca" readonly="readonly" value="{row.get('marca')}"&gt;&lt;/input&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>This is my JavaScript function "find_noeco_s":</p> <pre><code>function find_noeco_s(noeco,row){ objsal = row; if(window.XMLHttpRequest) ajax = new XMLHttpRequest(); else ajax = new ActiveXObject("Microsoft.XMLHTTP"); ajax.onreadystatechange = funcionCallback; ajax.open("GET", "/processEco.jsp?noeco="+noeco.value, true); ajax.send(""); </code></pre> <p>}</p> <p>And this is my JSP processEco:</p> <pre><code>String noeco = request.getParameter("noeco"); String exists=""; String matri= ""; HashMap row = new HashMap(); try{ PreparedStatement ps = PV.prepareStatement("select * from vehicles where econom=?"); ps.setString(1, noeco); ResultSet rs = ps.executeQuery(); if(rs.next()){ exists= rs.getString("dstipveh"); matri = rs.getString("matr"); marca= rs.getString("marca"); row.put("exists", exists); row.put("matr", matr); row.put("marca", marca); }else{ exists= "DOES NOT EXISTS"; row.put("exists", exists); } %&gt; &lt;%=row%&gt; &lt;% }finally{} %&gt; </code></pre> <p>But I get just one value (exists). Like I said, I'm not very familiar with JavaScript and JSP. So, how can I return several values and display this values in my JSP like I do with just one value?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload