how to get data in textbox from database when item selected in listbox in jsp without refreshing the page,
i had code that refresh the page.
if not in jsp even possible in javascript or any plz........thanxs in advance (max try in jsp)

You need to use Ajax for it. There are many decent Ajax frameworks out there which you can use with a minimalistic knowledge of Javascript. Your query is by far too generic, post your code if you get stuck and we might be in a better position to help you out.

This my code which will refresh the page

<%@ page import="java.sql.*,java.lang.*,java.util.*" %>
 <jsp:useBean id="dcon" scope="request" class="DBConnection.DBCon" />   

<%
                Connection con;
                con=dcon.getCon();
                String BSCODE=null;
                Statement st=con.createStatement();             
                String BSCODE1=request.getParameter("BSCODE");
%>

<form name="guideform" onsubmit="return Form_Validator(this)" action="pharma_finance_master_bs_ev1.jsp" method="get"> 

 <tr>
           <td colspan="4"><div align="left" class="tableHeading">BLANCESHEET:</div></td>
            </tr>
            <tr>
              <td width="30%">&nbsp;</td>
              <td colspan="3">&nbsp;</td>
            </tr>
         <tr>
              <td class="style11" id="list"><div align="right" >BalanceSheet Code: </div></td>
              <td colspan="3" align="left">
    <select name="lstCode" class="txtBoxBg" id="lstCode" onChange="window.location=document.guideform.lstCode.options[document.guideform.lstCode.selectedIndex].value">
    <option>--select code--</option>     
    <%
    ResultSet rs=st.executeQuery("select  BS_CODE from PHR_FIN_MST_BS");
    while(rs.next()){
                     BSCODE=rs.getString(1);
        if(BSCODE.equals(BSCODE1))
        {
    %>
    <OPTION selected value ><%out.println(BSCODE1);%> 
    <%
        }//if
        else
        {
    %>
    <OPTION value="pharma_finance_master_bs_ev.jsp?BSCODE=<%=BSCODE%>" ><%out.println(BSCODE);%> 
    <%
        }//else
    }//while
    rs.close();

    %>
             </select></td>
            </tr>

            <tr>
             <td class="style11"><div align="right">BalanceSheet Name: </div></td>
              <td colspan="3" align="left">                
                <div align="left">
                  <input name="txtSCName" type="text" class="txtBoxBg" id="txtSCName" size="50" 
    <%
    ResultSet rs1=st.executeQuery("select BS_NAME from PHR_FIN_MST_BS where BS_CODE='"+BSCODE1+"'");
    while(rs1.next()){
    %> 
    value= "<%out.println(rs1.getString(1));%>" >
    <% 
    }//while
    rs1.close();
    %>
                </div></td></tr>
            <tr>

> This my code which will refresh the page

Apart from being wrong on many counts, what kind of help do you need with this? It takes some kind of effort to convert an existing page into a page which uses Ajax. For this you need to learn Ajax, it's not something which someone can post for you.

Don't access database from a JSP. It's a view technology, so use it only for rendering. Keep the database accessing part restricted to servlets or EJB's if you are using them. When a item in the listbox is selected, fire a ajax request to a servlet with the value of the list item being passed to it. Inside the servlet, do you normal processing and just write the data you just fetched to the Servlet Output Stream. You can then access the result using the responseText property of the Ajax object in Javascript.

If all this seems to be alien to you, then you need to work with a few Ajax tutorials here and there to get a good grasp of how things work.

i learned ajax in these 3days, and also did some examples
and also following one example(select/dropdown) option i did it in jsp
but some problems occured in that can any one send that ajax using jsp code send

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.