Hi,
I have a JSP which is supposed to upload a file while storing other database information.
JSP
---
<form action="transcription" name="transcription" method="post" enctype="multipart/form-data">
<abc:text_input type="text" name="firstname"/>
<abc:text_input type="text" name="lastname"/>
<input type="file" name="attachment" />
</form>
In the Servlet, I use the MultipartRequest to get the value of the parameters:
Servlet
--------
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
beginRequest(request, response);
try
{
if (request.getMethod().equals("POST") && request.getContentType().startsWith("multipart/form-data"))
{
try
{
User user = getUser(request);
MultipartRequest parser = new ServletMultipartRequest(request, MultipartRequest.MAX_READ_BYTES * 10);
String action = this.getActionFromMultipartRequest(parser, "");
String lastname = parser.getURLParameter("lastname"),
String firstname = parser.getURLParameter("firstname"),
}
}
}
finally
{
endRequest();
}
}
Tag library
------------
text_inputTag.java
--------------------
Is there a way to get value of the lastname and firstname if I get it from the MutilpartRequest?
Thanks,
CeCe
I have a JSP which is supposed to upload a file while storing other database information.
JSP
---
<form action="transcription" name="transcription" method="post" enctype="multipart/form-data">
<abc:text_input type="text" name="firstname"/>
<abc:text_input type="text" name="lastname"/>
<input type="file" name="attachment" />
</form>
In the Servlet, I use the MultipartRequest to get the value of the parameters:
Servlet
--------
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
beginRequest(request, response);
try
{
if (request.getMethod().equals("POST") && request.getContentType().startsWith("multipart/form-data"))
{
try
{
User user = getUser(request);
MultipartRequest parser = new ServletMultipartRequest(request, MultipartRequest.MAX_READ_BYTES * 10);
String action = this.getActionFromMultipartRequest(parser, "");
String lastname = parser.getURLParameter("lastname"),
String firstname = parser.getURLParameter("firstname"),
}
}
}
finally
{
endRequest();
}
}
Tag library
------------
text_inputTag.java
--------------------
Is there a way to get value of the lastname and firstname if I get it from the MutilpartRequest?
Thanks,
CeCe