request.getParameter is returning null ,I have surfed a lot for this but i didn't got the proper solution












-1















So basically, when I try submitting my jsp, the control wents to the servlet , but the values of all the control in jsp becomes null



"ViewBook.jsp"



<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="Header_1.jsp" %>
<form action="<%=request.getContextPath()%>/BookServlet" method="post"
enctype="multipart/form-data">
<table>
<th colspan="2"></th>
<tr>
<td>
ID:
</td>
<td>
<input type="number" name="id">
</td>

</tr>
<tr>
<td>
Title:
</td>
<td>
<input type="text" name="title">
</td>
</tr>
<tr>
<td>
Author
</td>
<td>
<input type="text" name="author">
</td>

</tr>
<tr>
<td>
Price:
</td>
<td>
<input type="number" name="price">
</td>

</tr>
<tr>
<td>
Book image:
</td>
<td>
<input type="file" name="book_img">
</td>

</tr>
<tr>
<td>
Publish date:
</td>
<td>
<input type="date" name="pub_date">
</td>
</tr>
<tr>
<td>
<input type="submit" value="add" formaction="
<%=request.getContextPath()%>/BookServlet?action=add">
<input type="submit" value="delete"
formaction="G:sem5AJTQ-4srcjavaBookServle?action=delete">
<input type="submit" value="update" formaction="
<%=request.getContextPath()%>/BookServlet?action=update">
<input type="submit" value="view" formaction="
<%=request.getContextPath()%>/BookServlet?action=view">
</td>
</tr>
</table>
</form>

<%@include file="Footer.jsp" %>


"BookServlet.java"



@WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
public class BookServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");

}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try (PrintWriter out = response.getWriter()) {

}
}
// processRequest(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
String title=request.getParameter("title");
String author=request.getParameter("author");
String price=request.getParameter("price");
System.out.println("price=="+price);
String book_img=request.getParameter("book_img");
System.out.println("book:imagre===="+book_img);
String pub_date=request.getParameter("pub_date");
String action=request.getParameter("action");
SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
Date d = null;
try {
d = (Date) sdf.parse(pub_date);
} catch (Exception ex) {
System.out.println("Exception ex="+ex);
}
Part filepart=request.getPart("book_img");
System.out.println("part====="+filepart);
InputStream is=filepart.getInputStream();
BookBean bb=new BookBean();
// ResultSet rs=bb.ViewAllBooks();
if(action.equals("add"))
{
Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
bb.add(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
// processRequest(request, response);
}else if(action.equals("update"))
{ Book b=new
Book(0,title,author,Integer.parseInt(price),d,is);
// boolean flag= bb.update(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
}else if(action.equals("delete")){}
else if(action.equals("view")){}

}

@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>

}


This is what I got in my catch block
-Exception ex=java.lang.NullPointerException



StackTrace:



 java.lang.NullPointerException
at BookCrud.BookServlet.doPost(BookServlet.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:491)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:139)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke
(AbstractAccessLogValve.java:668)
at
org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:343)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process
(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process
(AbstractProtocol.java:764)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
(NioEndpoint.java:1388)
at
org.apache.tomcat.util.net.SocketProcessorBase.run
(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run
(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)


any help from your side
also, I have surfed a lot for this on StackOverflow and other websites but
I didn't get any proper solution for this.......










share|improve this question

























  • Can you share full exception trace?

    – codeLover
    Nov 17 '18 at 3:28











  • @codeLover i have added the stack trace

    – dubking India
    Nov 17 '18 at 3:33











  • which line is 136?

    – codeLover
    Nov 17 '18 at 3:36











  • here it is:-- Part filepart=request.getPart("book_img");

    – dubking India
    Nov 17 '18 at 3:38











  • but not only filepart ,my all variables are returning null

    – dubking India
    Nov 17 '18 at 3:39
















-1















So basically, when I try submitting my jsp, the control wents to the servlet , but the values of all the control in jsp becomes null



"ViewBook.jsp"



<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="Header_1.jsp" %>
<form action="<%=request.getContextPath()%>/BookServlet" method="post"
enctype="multipart/form-data">
<table>
<th colspan="2"></th>
<tr>
<td>
ID:
</td>
<td>
<input type="number" name="id">
</td>

</tr>
<tr>
<td>
Title:
</td>
<td>
<input type="text" name="title">
</td>
</tr>
<tr>
<td>
Author
</td>
<td>
<input type="text" name="author">
</td>

</tr>
<tr>
<td>
Price:
</td>
<td>
<input type="number" name="price">
</td>

</tr>
<tr>
<td>
Book image:
</td>
<td>
<input type="file" name="book_img">
</td>

</tr>
<tr>
<td>
Publish date:
</td>
<td>
<input type="date" name="pub_date">
</td>
</tr>
<tr>
<td>
<input type="submit" value="add" formaction="
<%=request.getContextPath()%>/BookServlet?action=add">
<input type="submit" value="delete"
formaction="G:sem5AJTQ-4srcjavaBookServle?action=delete">
<input type="submit" value="update" formaction="
<%=request.getContextPath()%>/BookServlet?action=update">
<input type="submit" value="view" formaction="
<%=request.getContextPath()%>/BookServlet?action=view">
</td>
</tr>
</table>
</form>

<%@include file="Footer.jsp" %>


"BookServlet.java"



@WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
public class BookServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");

}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try (PrintWriter out = response.getWriter()) {

}
}
// processRequest(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
String title=request.getParameter("title");
String author=request.getParameter("author");
String price=request.getParameter("price");
System.out.println("price=="+price);
String book_img=request.getParameter("book_img");
System.out.println("book:imagre===="+book_img);
String pub_date=request.getParameter("pub_date");
String action=request.getParameter("action");
SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
Date d = null;
try {
d = (Date) sdf.parse(pub_date);
} catch (Exception ex) {
System.out.println("Exception ex="+ex);
}
Part filepart=request.getPart("book_img");
System.out.println("part====="+filepart);
InputStream is=filepart.getInputStream();
BookBean bb=new BookBean();
// ResultSet rs=bb.ViewAllBooks();
if(action.equals("add"))
{
Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
bb.add(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
// processRequest(request, response);
}else if(action.equals("update"))
{ Book b=new
Book(0,title,author,Integer.parseInt(price),d,is);
// boolean flag= bb.update(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
}else if(action.equals("delete")){}
else if(action.equals("view")){}

}

@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>

}


This is what I got in my catch block
-Exception ex=java.lang.NullPointerException



StackTrace:



 java.lang.NullPointerException
at BookCrud.BookServlet.doPost(BookServlet.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:491)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:139)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke
(AbstractAccessLogValve.java:668)
at
org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:343)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process
(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process
(AbstractProtocol.java:764)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
(NioEndpoint.java:1388)
at
org.apache.tomcat.util.net.SocketProcessorBase.run
(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run
(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)


any help from your side
also, I have surfed a lot for this on StackOverflow and other websites but
I didn't get any proper solution for this.......










share|improve this question

























  • Can you share full exception trace?

    – codeLover
    Nov 17 '18 at 3:28











  • @codeLover i have added the stack trace

    – dubking India
    Nov 17 '18 at 3:33











  • which line is 136?

    – codeLover
    Nov 17 '18 at 3:36











  • here it is:-- Part filepart=request.getPart("book_img");

    – dubking India
    Nov 17 '18 at 3:38











  • but not only filepart ,my all variables are returning null

    – dubking India
    Nov 17 '18 at 3:39














-1












-1








-1








So basically, when I try submitting my jsp, the control wents to the servlet , but the values of all the control in jsp becomes null



"ViewBook.jsp"



<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="Header_1.jsp" %>
<form action="<%=request.getContextPath()%>/BookServlet" method="post"
enctype="multipart/form-data">
<table>
<th colspan="2"></th>
<tr>
<td>
ID:
</td>
<td>
<input type="number" name="id">
</td>

</tr>
<tr>
<td>
Title:
</td>
<td>
<input type="text" name="title">
</td>
</tr>
<tr>
<td>
Author
</td>
<td>
<input type="text" name="author">
</td>

</tr>
<tr>
<td>
Price:
</td>
<td>
<input type="number" name="price">
</td>

</tr>
<tr>
<td>
Book image:
</td>
<td>
<input type="file" name="book_img">
</td>

</tr>
<tr>
<td>
Publish date:
</td>
<td>
<input type="date" name="pub_date">
</td>
</tr>
<tr>
<td>
<input type="submit" value="add" formaction="
<%=request.getContextPath()%>/BookServlet?action=add">
<input type="submit" value="delete"
formaction="G:sem5AJTQ-4srcjavaBookServle?action=delete">
<input type="submit" value="update" formaction="
<%=request.getContextPath()%>/BookServlet?action=update">
<input type="submit" value="view" formaction="
<%=request.getContextPath()%>/BookServlet?action=view">
</td>
</tr>
</table>
</form>

<%@include file="Footer.jsp" %>


"BookServlet.java"



@WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
public class BookServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");

}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try (PrintWriter out = response.getWriter()) {

}
}
// processRequest(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
String title=request.getParameter("title");
String author=request.getParameter("author");
String price=request.getParameter("price");
System.out.println("price=="+price);
String book_img=request.getParameter("book_img");
System.out.println("book:imagre===="+book_img);
String pub_date=request.getParameter("pub_date");
String action=request.getParameter("action");
SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
Date d = null;
try {
d = (Date) sdf.parse(pub_date);
} catch (Exception ex) {
System.out.println("Exception ex="+ex);
}
Part filepart=request.getPart("book_img");
System.out.println("part====="+filepart);
InputStream is=filepart.getInputStream();
BookBean bb=new BookBean();
// ResultSet rs=bb.ViewAllBooks();
if(action.equals("add"))
{
Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
bb.add(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
// processRequest(request, response);
}else if(action.equals("update"))
{ Book b=new
Book(0,title,author,Integer.parseInt(price),d,is);
// boolean flag= bb.update(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
}else if(action.equals("delete")){}
else if(action.equals("view")){}

}

@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>

}


This is what I got in my catch block
-Exception ex=java.lang.NullPointerException



StackTrace:



 java.lang.NullPointerException
at BookCrud.BookServlet.doPost(BookServlet.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:491)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:139)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke
(AbstractAccessLogValve.java:668)
at
org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:343)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process
(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process
(AbstractProtocol.java:764)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
(NioEndpoint.java:1388)
at
org.apache.tomcat.util.net.SocketProcessorBase.run
(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run
(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)


any help from your side
also, I have surfed a lot for this on StackOverflow and other websites but
I didn't get any proper solution for this.......










share|improve this question
















So basically, when I try submitting my jsp, the control wents to the servlet , but the values of all the control in jsp becomes null



"ViewBook.jsp"



<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="Header_1.jsp" %>
<form action="<%=request.getContextPath()%>/BookServlet" method="post"
enctype="multipart/form-data">
<table>
<th colspan="2"></th>
<tr>
<td>
ID:
</td>
<td>
<input type="number" name="id">
</td>

</tr>
<tr>
<td>
Title:
</td>
<td>
<input type="text" name="title">
</td>
</tr>
<tr>
<td>
Author
</td>
<td>
<input type="text" name="author">
</td>

</tr>
<tr>
<td>
Price:
</td>
<td>
<input type="number" name="price">
</td>

</tr>
<tr>
<td>
Book image:
</td>
<td>
<input type="file" name="book_img">
</td>

</tr>
<tr>
<td>
Publish date:
</td>
<td>
<input type="date" name="pub_date">
</td>
</tr>
<tr>
<td>
<input type="submit" value="add" formaction="
<%=request.getContextPath()%>/BookServlet?action=add">
<input type="submit" value="delete"
formaction="G:sem5AJTQ-4srcjavaBookServle?action=delete">
<input type="submit" value="update" formaction="
<%=request.getContextPath()%>/BookServlet?action=update">
<input type="submit" value="view" formaction="
<%=request.getContextPath()%>/BookServlet?action=view">
</td>
</tr>
</table>
</form>

<%@include file="Footer.jsp" %>


"BookServlet.java"



@WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
public class BookServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");

}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try (PrintWriter out = response.getWriter()) {

}
}
// processRequest(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
String title=request.getParameter("title");
String author=request.getParameter("author");
String price=request.getParameter("price");
System.out.println("price=="+price);
String book_img=request.getParameter("book_img");
System.out.println("book:imagre===="+book_img);
String pub_date=request.getParameter("pub_date");
String action=request.getParameter("action");
SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
Date d = null;
try {
d = (Date) sdf.parse(pub_date);
} catch (Exception ex) {
System.out.println("Exception ex="+ex);
}
Part filepart=request.getPart("book_img");
System.out.println("part====="+filepart);
InputStream is=filepart.getInputStream();
BookBean bb=new BookBean();
// ResultSet rs=bb.ViewAllBooks();
if(action.equals("add"))
{
Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
bb.add(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
// processRequest(request, response);
}else if(action.equals("update"))
{ Book b=new
Book(0,title,author,Integer.parseInt(price),d,is);
// boolean flag= bb.update(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
}else if(action.equals("delete")){}
else if(action.equals("view")){}

}

@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>

}


This is what I got in my catch block
-Exception ex=java.lang.NullPointerException



StackTrace:



 java.lang.NullPointerException
at BookCrud.BookServlet.doPost(BookServlet.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:491)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:139)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke
(AbstractAccessLogValve.java:668)
at
org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:343)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process
(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process
(AbstractProtocol.java:764)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
(NioEndpoint.java:1388)
at
org.apache.tomcat.util.net.SocketProcessorBase.run
(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run
(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)


any help from your side
also, I have surfed a lot for this on StackOverflow and other websites but
I didn't get any proper solution for this.......







java jsp servlets






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 4:32







dubking India

















asked Nov 17 '18 at 3:24









dubking Indiadubking India

134




134













  • Can you share full exception trace?

    – codeLover
    Nov 17 '18 at 3:28











  • @codeLover i have added the stack trace

    – dubking India
    Nov 17 '18 at 3:33











  • which line is 136?

    – codeLover
    Nov 17 '18 at 3:36











  • here it is:-- Part filepart=request.getPart("book_img");

    – dubking India
    Nov 17 '18 at 3:38











  • but not only filepart ,my all variables are returning null

    – dubking India
    Nov 17 '18 at 3:39



















  • Can you share full exception trace?

    – codeLover
    Nov 17 '18 at 3:28











  • @codeLover i have added the stack trace

    – dubking India
    Nov 17 '18 at 3:33











  • which line is 136?

    – codeLover
    Nov 17 '18 at 3:36











  • here it is:-- Part filepart=request.getPart("book_img");

    – dubking India
    Nov 17 '18 at 3:38











  • but not only filepart ,my all variables are returning null

    – dubking India
    Nov 17 '18 at 3:39

















Can you share full exception trace?

– codeLover
Nov 17 '18 at 3:28





Can you share full exception trace?

– codeLover
Nov 17 '18 at 3:28













@codeLover i have added the stack trace

– dubking India
Nov 17 '18 at 3:33





@codeLover i have added the stack trace

– dubking India
Nov 17 '18 at 3:33













which line is 136?

– codeLover
Nov 17 '18 at 3:36





which line is 136?

– codeLover
Nov 17 '18 at 3:36













here it is:-- Part filepart=request.getPart("book_img");

– dubking India
Nov 17 '18 at 3:38





here it is:-- Part filepart=request.getPart("book_img");

– dubking India
Nov 17 '18 at 3:38













but not only filepart ,my all variables are returning null

– dubking India
Nov 17 '18 at 3:39





but not only filepart ,my all variables are returning null

– dubking India
Nov 17 '18 at 3:39












2 Answers
2






active

oldest

votes


















0














you can not directly get parameters by using request.getParameter(name);. While using it, form fields aren't available as parameter of the request, they are included in the stream, so you can not get it the normal way.



Refer this: http://commons.apache.org/proper/commons-fileupload//using.html, under the section Processing the uploaded items.






share|improve this answer
























  • thanks a lot for this!!! but i wanted to know the reason behind that because in one of my friend's computer this code is working fine...

    – dubking India
    Nov 17 '18 at 6:55











  • I will accept this as an answer, but please help me to understand the reason behind that! why we cannot directly use request.getParameter()?? and also this code runs perfectly fine in my friend's pc ....hope you will help me to understand

    – dubking India
    Nov 17 '18 at 8:24











  • Not sure, how the other code looks like. The below thread gives detailed answer on the behavior: stackoverflow.com/questions/2422468/…… and w3.org/TR/html4/interact/forms.html Hope this helps and post your comments if any queries. Are you/your friend using servlet 3.0 or newer?

    – secret super star
    Nov 17 '18 at 8:47





















0














For all those who are facing the same error ::You can use jar files as mentioned by @secret super star ,But if you dont want to do so here is a tip :



Just



import javax.servlet.annotation.MultipartConfig; 


in your servlet and add



@MultipartConfig(maxFileSize = 16177215)    //Length of the file


annotation ,That's it



Note: In my case following will be my servlet



@WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
@MultipartConfig(maxFileSize = 16177215)
public class BookServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");

}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try (PrintWriter out = response.getWriter()) {

}
}
// processRequest(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
String title=request.getParameter("title");
String author=request.getParameter("author");
String price=request.getParameter("price");
System.out.println("price=="+price);
String book_img=request.getParameter("book_img");
System.out.println("book:imagre===="+book_img);
String pub_date=request.getParameter("pub_date");
String action=request.getParameter("action");
SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
Date d = null;
try {
d = (Date) sdf.parse(pub_date);
} catch (Exception ex) {
System.out.println("Exception ex="+ex);
}
Part filepart=request.getPart("book_img");
System.out.println("part====="+filepart);
InputStream is=filepart.getInputStream();
BookBean bb=new BookBean();
// ResultSet rs=bb.ViewAllBooks();
if(action.equals("add"))
{
Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
bb.add(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
// processRequest(request, response);
}else if(action.equals("update"))
{ Book b=new
Book(0,title,author,Integer.parseInt(price),d,is);
// boolean flag= bb.update(b);
HttpSession s=request.getSession(true);
// s.setAttribute("rs", rs);
RequestDispatcher
rd=request.getRequestDispatcher("ViewAllBooks.jsp");
rd.forward(request, response);
}else if(action.equals("delete")){}
else if(action.equals("view")){}

}

@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>

}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347896%2frequest-getparameter-is-returning-null-i-have-surfed-a-lot-for-this-but-i-didn%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    you can not directly get parameters by using request.getParameter(name);. While using it, form fields aren't available as parameter of the request, they are included in the stream, so you can not get it the normal way.



    Refer this: http://commons.apache.org/proper/commons-fileupload//using.html, under the section Processing the uploaded items.






    share|improve this answer
























    • thanks a lot for this!!! but i wanted to know the reason behind that because in one of my friend's computer this code is working fine...

      – dubking India
      Nov 17 '18 at 6:55











    • I will accept this as an answer, but please help me to understand the reason behind that! why we cannot directly use request.getParameter()?? and also this code runs perfectly fine in my friend's pc ....hope you will help me to understand

      – dubking India
      Nov 17 '18 at 8:24











    • Not sure, how the other code looks like. The below thread gives detailed answer on the behavior: stackoverflow.com/questions/2422468/…… and w3.org/TR/html4/interact/forms.html Hope this helps and post your comments if any queries. Are you/your friend using servlet 3.0 or newer?

      – secret super star
      Nov 17 '18 at 8:47


















    0














    you can not directly get parameters by using request.getParameter(name);. While using it, form fields aren't available as parameter of the request, they are included in the stream, so you can not get it the normal way.



    Refer this: http://commons.apache.org/proper/commons-fileupload//using.html, under the section Processing the uploaded items.






    share|improve this answer
























    • thanks a lot for this!!! but i wanted to know the reason behind that because in one of my friend's computer this code is working fine...

      – dubking India
      Nov 17 '18 at 6:55











    • I will accept this as an answer, but please help me to understand the reason behind that! why we cannot directly use request.getParameter()?? and also this code runs perfectly fine in my friend's pc ....hope you will help me to understand

      – dubking India
      Nov 17 '18 at 8:24











    • Not sure, how the other code looks like. The below thread gives detailed answer on the behavior: stackoverflow.com/questions/2422468/…… and w3.org/TR/html4/interact/forms.html Hope this helps and post your comments if any queries. Are you/your friend using servlet 3.0 or newer?

      – secret super star
      Nov 17 '18 at 8:47
















    0












    0








    0







    you can not directly get parameters by using request.getParameter(name);. While using it, form fields aren't available as parameter of the request, they are included in the stream, so you can not get it the normal way.



    Refer this: http://commons.apache.org/proper/commons-fileupload//using.html, under the section Processing the uploaded items.






    share|improve this answer













    you can not directly get parameters by using request.getParameter(name);. While using it, form fields aren't available as parameter of the request, they are included in the stream, so you can not get it the normal way.



    Refer this: http://commons.apache.org/proper/commons-fileupload//using.html, under the section Processing the uploaded items.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 17 '18 at 4:49









    secret super starsecret super star

    943114




    943114













    • thanks a lot for this!!! but i wanted to know the reason behind that because in one of my friend's computer this code is working fine...

      – dubking India
      Nov 17 '18 at 6:55











    • I will accept this as an answer, but please help me to understand the reason behind that! why we cannot directly use request.getParameter()?? and also this code runs perfectly fine in my friend's pc ....hope you will help me to understand

      – dubking India
      Nov 17 '18 at 8:24











    • Not sure, how the other code looks like. The below thread gives detailed answer on the behavior: stackoverflow.com/questions/2422468/…… and w3.org/TR/html4/interact/forms.html Hope this helps and post your comments if any queries. Are you/your friend using servlet 3.0 or newer?

      – secret super star
      Nov 17 '18 at 8:47





















    • thanks a lot for this!!! but i wanted to know the reason behind that because in one of my friend's computer this code is working fine...

      – dubking India
      Nov 17 '18 at 6:55











    • I will accept this as an answer, but please help me to understand the reason behind that! why we cannot directly use request.getParameter()?? and also this code runs perfectly fine in my friend's pc ....hope you will help me to understand

      – dubking India
      Nov 17 '18 at 8:24











    • Not sure, how the other code looks like. The below thread gives detailed answer on the behavior: stackoverflow.com/questions/2422468/…… and w3.org/TR/html4/interact/forms.html Hope this helps and post your comments if any queries. Are you/your friend using servlet 3.0 or newer?

      – secret super star
      Nov 17 '18 at 8:47



















    thanks a lot for this!!! but i wanted to know the reason behind that because in one of my friend's computer this code is working fine...

    – dubking India
    Nov 17 '18 at 6:55





    thanks a lot for this!!! but i wanted to know the reason behind that because in one of my friend's computer this code is working fine...

    – dubking India
    Nov 17 '18 at 6:55













    I will accept this as an answer, but please help me to understand the reason behind that! why we cannot directly use request.getParameter()?? and also this code runs perfectly fine in my friend's pc ....hope you will help me to understand

    – dubking India
    Nov 17 '18 at 8:24





    I will accept this as an answer, but please help me to understand the reason behind that! why we cannot directly use request.getParameter()?? and also this code runs perfectly fine in my friend's pc ....hope you will help me to understand

    – dubking India
    Nov 17 '18 at 8:24













    Not sure, how the other code looks like. The below thread gives detailed answer on the behavior: stackoverflow.com/questions/2422468/…… and w3.org/TR/html4/interact/forms.html Hope this helps and post your comments if any queries. Are you/your friend using servlet 3.0 or newer?

    – secret super star
    Nov 17 '18 at 8:47







    Not sure, how the other code looks like. The below thread gives detailed answer on the behavior: stackoverflow.com/questions/2422468/…… and w3.org/TR/html4/interact/forms.html Hope this helps and post your comments if any queries. Are you/your friend using servlet 3.0 or newer?

    – secret super star
    Nov 17 '18 at 8:47















    0














    For all those who are facing the same error ::You can use jar files as mentioned by @secret super star ,But if you dont want to do so here is a tip :



    Just



    import javax.servlet.annotation.MultipartConfig; 


    in your servlet and add



    @MultipartConfig(maxFileSize = 16177215)    //Length of the file


    annotation ,That's it



    Note: In my case following will be my servlet



    @WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
    @MultipartConfig(maxFileSize = 16177215)
    public class BookServlet extends HttpServlet {
    protected void processRequest(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse
    response)
    throws ServletException, IOException {
    try (PrintWriter out = response.getWriter()) {

    }
    }
    // processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse
    response)
    throws ServletException, IOException {
    String title=request.getParameter("title");
    String author=request.getParameter("author");
    String price=request.getParameter("price");
    System.out.println("price=="+price);
    String book_img=request.getParameter("book_img");
    System.out.println("book:imagre===="+book_img);
    String pub_date=request.getParameter("pub_date");
    String action=request.getParameter("action");
    SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
    Date d = null;
    try {
    d = (Date) sdf.parse(pub_date);
    } catch (Exception ex) {
    System.out.println("Exception ex="+ex);
    }
    Part filepart=request.getPart("book_img");
    System.out.println("part====="+filepart);
    InputStream is=filepart.getInputStream();
    BookBean bb=new BookBean();
    // ResultSet rs=bb.ViewAllBooks();
    if(action.equals("add"))
    {
    Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
    bb.add(b);
    HttpSession s=request.getSession(true);
    // s.setAttribute("rs", rs);
    RequestDispatcher
    rd=request.getRequestDispatcher("ViewAllBooks.jsp");
    rd.forward(request, response);
    // processRequest(request, response);
    }else if(action.equals("update"))
    { Book b=new
    Book(0,title,author,Integer.parseInt(price),d,is);
    // boolean flag= bb.update(b);
    HttpSession s=request.getSession(true);
    // s.setAttribute("rs", rs);
    RequestDispatcher
    rd=request.getRequestDispatcher("ViewAllBooks.jsp");
    rd.forward(request, response);
    }else if(action.equals("delete")){}
    else if(action.equals("view")){}

    }

    @Override
    public String getServletInfo() {
    return "Short description";
    }// </editor-fold>

    }





    share|improve this answer




























      0














      For all those who are facing the same error ::You can use jar files as mentioned by @secret super star ,But if you dont want to do so here is a tip :



      Just



      import javax.servlet.annotation.MultipartConfig; 


      in your servlet and add



      @MultipartConfig(maxFileSize = 16177215)    //Length of the file


      annotation ,That's it



      Note: In my case following will be my servlet



      @WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
      @MultipartConfig(maxFileSize = 16177215)
      public class BookServlet extends HttpServlet {
      protected void processRequest(HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {
      response.setContentType("text/html;charset=UTF-8");

      }

      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse
      response)
      throws ServletException, IOException {
      try (PrintWriter out = response.getWriter()) {

      }
      }
      // processRequest(request, response);
      }

      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse
      response)
      throws ServletException, IOException {
      String title=request.getParameter("title");
      String author=request.getParameter("author");
      String price=request.getParameter("price");
      System.out.println("price=="+price);
      String book_img=request.getParameter("book_img");
      System.out.println("book:imagre===="+book_img);
      String pub_date=request.getParameter("pub_date");
      String action=request.getParameter("action");
      SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
      Date d = null;
      try {
      d = (Date) sdf.parse(pub_date);
      } catch (Exception ex) {
      System.out.println("Exception ex="+ex);
      }
      Part filepart=request.getPart("book_img");
      System.out.println("part====="+filepart);
      InputStream is=filepart.getInputStream();
      BookBean bb=new BookBean();
      // ResultSet rs=bb.ViewAllBooks();
      if(action.equals("add"))
      {
      Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
      bb.add(b);
      HttpSession s=request.getSession(true);
      // s.setAttribute("rs", rs);
      RequestDispatcher
      rd=request.getRequestDispatcher("ViewAllBooks.jsp");
      rd.forward(request, response);
      // processRequest(request, response);
      }else if(action.equals("update"))
      { Book b=new
      Book(0,title,author,Integer.parseInt(price),d,is);
      // boolean flag= bb.update(b);
      HttpSession s=request.getSession(true);
      // s.setAttribute("rs", rs);
      RequestDispatcher
      rd=request.getRequestDispatcher("ViewAllBooks.jsp");
      rd.forward(request, response);
      }else if(action.equals("delete")){}
      else if(action.equals("view")){}

      }

      @Override
      public String getServletInfo() {
      return "Short description";
      }// </editor-fold>

      }





      share|improve this answer


























        0












        0








        0







        For all those who are facing the same error ::You can use jar files as mentioned by @secret super star ,But if you dont want to do so here is a tip :



        Just



        import javax.servlet.annotation.MultipartConfig; 


        in your servlet and add



        @MultipartConfig(maxFileSize = 16177215)    //Length of the file


        annotation ,That's it



        Note: In my case following will be my servlet



        @WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
        @MultipartConfig(maxFileSize = 16177215)
        public class BookServlet extends HttpServlet {
        protected void processRequest(HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");

        }

        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse
        response)
        throws ServletException, IOException {
        try (PrintWriter out = response.getWriter()) {

        }
        }
        // processRequest(request, response);
        }

        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse
        response)
        throws ServletException, IOException {
        String title=request.getParameter("title");
        String author=request.getParameter("author");
        String price=request.getParameter("price");
        System.out.println("price=="+price);
        String book_img=request.getParameter("book_img");
        System.out.println("book:imagre===="+book_img);
        String pub_date=request.getParameter("pub_date");
        String action=request.getParameter("action");
        SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
        Date d = null;
        try {
        d = (Date) sdf.parse(pub_date);
        } catch (Exception ex) {
        System.out.println("Exception ex="+ex);
        }
        Part filepart=request.getPart("book_img");
        System.out.println("part====="+filepart);
        InputStream is=filepart.getInputStream();
        BookBean bb=new BookBean();
        // ResultSet rs=bb.ViewAllBooks();
        if(action.equals("add"))
        {
        Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
        bb.add(b);
        HttpSession s=request.getSession(true);
        // s.setAttribute("rs", rs);
        RequestDispatcher
        rd=request.getRequestDispatcher("ViewAllBooks.jsp");
        rd.forward(request, response);
        // processRequest(request, response);
        }else if(action.equals("update"))
        { Book b=new
        Book(0,title,author,Integer.parseInt(price),d,is);
        // boolean flag= bb.update(b);
        HttpSession s=request.getSession(true);
        // s.setAttribute("rs", rs);
        RequestDispatcher
        rd=request.getRequestDispatcher("ViewAllBooks.jsp");
        rd.forward(request, response);
        }else if(action.equals("delete")){}
        else if(action.equals("view")){}

        }

        @Override
        public String getServletInfo() {
        return "Short description";
        }// </editor-fold>

        }





        share|improve this answer













        For all those who are facing the same error ::You can use jar files as mentioned by @secret super star ,But if you dont want to do so here is a tip :



        Just



        import javax.servlet.annotation.MultipartConfig; 


        in your servlet and add



        @MultipartConfig(maxFileSize = 16177215)    //Length of the file


        annotation ,That's it



        Note: In my case following will be my servlet



        @WebServlet (name="BookServlet", urlPatterns = {"/BookServlet"})
        @MultipartConfig(maxFileSize = 16177215)
        public class BookServlet extends HttpServlet {
        protected void processRequest(HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");

        }

        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse
        response)
        throws ServletException, IOException {
        try (PrintWriter out = response.getWriter()) {

        }
        }
        // processRequest(request, response);
        }

        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse
        response)
        throws ServletException, IOException {
        String title=request.getParameter("title");
        String author=request.getParameter("author");
        String price=request.getParameter("price");
        System.out.println("price=="+price);
        String book_img=request.getParameter("book_img");
        System.out.println("book:imagre===="+book_img);
        String pub_date=request.getParameter("pub_date");
        String action=request.getParameter("action");
        SimpleDateFormat sdf=new SimpleDateFormat("mm/dd/yyyy");
        Date d = null;
        try {
        d = (Date) sdf.parse(pub_date);
        } catch (Exception ex) {
        System.out.println("Exception ex="+ex);
        }
        Part filepart=request.getPart("book_img");
        System.out.println("part====="+filepart);
        InputStream is=filepart.getInputStream();
        BookBean bb=new BookBean();
        // ResultSet rs=bb.ViewAllBooks();
        if(action.equals("add"))
        {
        Book b=new Book(0,title,author,Integer.parseInt(price),d,is);
        bb.add(b);
        HttpSession s=request.getSession(true);
        // s.setAttribute("rs", rs);
        RequestDispatcher
        rd=request.getRequestDispatcher("ViewAllBooks.jsp");
        rd.forward(request, response);
        // processRequest(request, response);
        }else if(action.equals("update"))
        { Book b=new
        Book(0,title,author,Integer.parseInt(price),d,is);
        // boolean flag= bb.update(b);
        HttpSession s=request.getSession(true);
        // s.setAttribute("rs", rs);
        RequestDispatcher
        rd=request.getRequestDispatcher("ViewAllBooks.jsp");
        rd.forward(request, response);
        }else if(action.equals("delete")){}
        else if(action.equals("view")){}

        }

        @Override
        public String getServletInfo() {
        return "Short description";
        }// </editor-fold>

        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '18 at 20:28









        dubking Indiadubking India

        134




        134






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347896%2frequest-getparameter-is-returning-null-i-have-surfed-a-lot-for-this-but-i-didn%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks