I m trying to pass formatted text from a text-editor that has been embedded in my jsp file. I m using enctype="multipart/form-data" in my form tag. I can pass the parameters to underyling servlet when using the default enctype. But I get null when using the multipart/form-data enctype in my servlet.
My form
<form action="pdfGenServlet" method="post" enctype="multipart/form-data">
<!-- input notes title-->
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" placeholder="Title of the notes" name="title">
</div>
</div>
<!-- input notes description-->
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter short description" name="description">
</div>
</div>
<div class="form-group">
<textarea name="content" id="myEditor"></textarea>
<div id="button-panel" class="panel panel-default">
<p>
<button type="submit" class="btn btn-primary "><span class="glyphicon glyphicon-plus"></span><strong> Create Note</strong></button>
<button class="btn btn-primary" type="reset"><strong>Reset</strong></button>
</p><!-- buttons -->
</div><!-- panel Button -->
</div>
</form>
My pdfGenServlet.java
@WebServlet("/pdfGenServlet")
public class pdfGenServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
// Get the text that will be added to the PDF
request.setCharacterEncoding("UTF-8");
String title = request.getParameter("title");
String description = request.getParameter("description");
String notes_content = request.getParameter("content");
Date date = new Date();
} catch(exception e)
{e.printStackTrace();}
}