Sunday, 15 August 2010

java - Passing hidden input value from jsp to servlet -


I am trying to generate an excel file when any link is clicked without redirecting anywhere. I make it in the servlet, but when I try to get the value of the hidden input, I get a zero pointing invention. The code I'm using

JSP

  & lt; Html: form action = "/ UploadExcel.do" enctype = "multipart / form-data" method = "post" & gt; & Lt; A href = "#" onclick = "ExcelFiller.fill" & gt; Download Excel & lt; / A & gt; & Lt; Input type = "hidden" name = "ribbag id" id = "refBgcId" value = "84" & gt; & Lt; / Input & gt; & Lt; / Html: form & gt;  

servlet

  public class excelfiller.httpservlet {personal constant last long serial warsuiuiid = 1l; Public Zero Init (Circlet Config Config) has servlet upption {super.init (config); } Public Zero Destroy () {} Secure Zero DoGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {System.out.println ("Created in This Sablet"); DoPost (request, response); } Secure zero doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {System.out.println ("in DoPost"); Http session session = (Http session) request.getSession (wrong); String log INUSIRID = (string) session.getAttribute ("strUserId"); {Refer to string = request.getParameter ("refBgcId"). ToString (); / * NULL POINTER EXCEPTION * / ArrayList & lt; String & gt; Details = New ArrayList & lt; String & gt; (); Details = Uploads BGCAO.Gate Details (Referral); CreateExcel (request, feedback, details, loggedInUserId); } Hold (exception e) {e.printStackTrace (); }}}  

I have tried to find a solution in response to similar questions on this site but I still can not do this work. Can anyone tell me what I am doing wrong?

You specify the parameters in the url in JavaScript as:

  var refBgcId = 84; Var url = "/UploadExcel.do?refBgcId="+refBgcId; Window.location.href = url;  

In more servlets, you can use

  as the string refBgcId = request.getParameter ("refBgcId"). ToString ();  

No comments:

Post a Comment