4 Replies - 21055 Views - Last Post: 06 April 2008 - 11:29 PM

#1 anamika  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 01-April 08

calling servlet without submit button

Posted 06 April 2008 - 03:44 AM

hi
i have multiple radio buttons on my html page.
On selection of each radiobutton a box kind of thing opens(by toggling down) in which data is displayed from the database.
On click of the radiobutton i want to call the servlet and also toggle(down) to open that box.
i m using a href fro toggling up(close that box).
There is no submit button on that page ho do i do it?
Is This A Good Question/Topic? 0
  • +

Replies To: calling servlet without submit button

#2 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: calling servlet without submit button

Posted 06 April 2008 - 07:52 PM

<input type=submit value="Submit"



:code:
Was This Post Helpful? 0
  • +
  • -

#3 anamika  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 01-April 08

Re: calling servlet without submit button

Posted 06 April 2008 - 10:09 PM

View Postno2pencil, on 6 Apr, 2008 - 07:52 PM, said:

<input type=submit value="Submit"



:code:



Please read my question properly......i have asked how to call the servlet without submit button.
i have read the documents and dint find the answer.
i guess that should be ok.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: calling servlet without submit button

Posted 06 April 2008 - 10:12 PM

View Postanamika, on 7 Apr, 2008 - 01:09 AM, said:

Please read my question properly......i have asked how to call the servlet without submit button.
i have read the documents and dint find the answer.
i guess that should be ok.

Sorry, I did miss-read it. Can you post your servlet code? Cuz I'm not sure what you are trying to do with radio buttons. On Change event would work, but if they selected the wrong one...
Was This Post Helpful? 0
  • +
  • -

#5 anamika  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 01-April 08

Re: calling servlet without submit button

Posted 06 April 2008 - 11:29 PM

View Postno2pencil, on 6 Apr, 2008 - 10:12 PM, said:

View Postanamika, on 7 Apr, 2008 - 01:09 AM, said:

Please read my question properly......i have asked how to call the servlet without submit button.
i have read the documents and dint find the answer.
i guess that should be ok.

Sorry, I did miss-read it. Can you post your servlet code? Cuz I'm not sure what you are trying to do with radio buttons. On Change event would work, but if they selected the wrong one...














This is my servlet (AccountAction) which calls AccountDAO....
On selection of radiobutton it should give the value as accname to the servlet...
on clicKing dwnward arrow it should toggle down the hidden box. At the same time it shud call servlet n give details....
I m facing prob in calling servlet in jsp...
the form is not getting submitted...i have used javascript for submitting which is caled on onclick event of the downward arrow
The javascript function is below:
mbk is form id...

<script type="text/javascript" >
function sub()
{


document.getElementById("mbk").submit();


}
</script>





ACCOUNTACTION::
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import java.util.ArrayList;

public class AccountAction extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
HttpSession sess= req.getSession();
System.out.println("into servlet");


String accname=req.getParameter("radiobutton") ;

AccountDAO acc=new AccountDAO();
ArrayList a=acc.dataconnect(accname);


req.setAttribute("Dw_Mgr_on",a.get(0));
req.setAttribute("Dw_Mgr_of",a.get(1));
req.setAttribute("Del_Mgr_of",a.get(2));
req.setAttribute("Client_Partner",a.get(3));
req.setAttribute("Location_ON",a.get(4));
req.setAttribute("Location_OFF",a.get(5));
req.setAttribute("Start_DT",a.get(6));
req.setAttribute("Status",a.get(7));
req.setAttribute("Last_Mtrc_Clctn_Dt",a.get(8));
req.setAttribute("Ovral_Mtrc_status",a.get(9));

RequestDispatcher view = req.getRequestDispatcher("inner.jsp");
view.forward(req,res);

}
}





ACCOUNTDAO::


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.*;
import java.util.*;


public class AccountDAO
{ ArrayList AL;
ArrayList dataconnect(String acc_name)
{
try
{



AL=new ArrayList(20);

Connection con = new Connectionhelper().connectDB();
PreparedStatement pst = con.prepareStatement("select * from DWLS_ACCOUNT where ACCT_NAME=?");
pst.setString(1,acc_name);
ResultSet rs = pst.executeQuery();

while(rs.next())
{

AL.add(rs.getString("ACCT_DW_MGR_ON"));

AL.add(rs.getString("ACCT_DW_MGR_OFF"));
AL.add(rs.getString("ACCT_DEL_MGR_OFF"));
AL.add(rs.getString("ACCT_CLIENT_PARTNER"));
AL.add(rs.getString("ACCT_LOCATION_ON"));
AL.add(rs.getString("ACCT_LOCATION_OFF"));
AL.add(rs.getString("ACCT_START_DT"));
AL.add(rs.getString("ACCT_STATUS"));
AL.add(rs.getString("LAST_MTRC_CLCTN_DT"));
AL.add(rs.getString("OVRAL_MTRC_STATUS"));
}

rs.close();
con.close();
}catch (SQLException e) { System.out.println("error");
e.printStackTrace();
}

return AL;

}
}
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1