Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

com.oreilly.servlet problem  RSS feed

 
John Vemuvella
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks,
I'm trying to get the inputstream from a uploaded file and also trying to grab some hidden parameter values. I'm using the oreilly file upload classes to do the same. The problem is that I'm losing the content when processing proceeds to the next part. The InputStream is getting lost even though I store it in a private variable. I need to be able to hold the value and return it when the appropriate method is called from a JSP. I can get the filename and my paraeter values, but not the file content. The code skeleton follows:
###################################################
private String paramList=null;
private String fileName=null;
private InputStream content=null;
public void getMultiFormContent(HttpServletRequest p_request){
try
{
String l_fileName="";
String l_paramList="?";
MultipartParser mp = new MultipartParser(p_request, 10*1024*1024); // 10MB

// Get file name and content
Part part1;
while ((part1 = mp.readNextPart()) != null)
{
if (part1.isFile())
{
// it's a file part
FilePart filePart = (FilePart) part1;
this.fileName = filePart.getFileName();
if (fileName != null)
{
this.content = filePart.getInputStream();
}
}
}
// Get required parameters
Part part;
while ((part = mp.readNextPart()) != null)
{
if (part.isParam()) {
// it's a parameter part
ParamPart paramPart = (ParamPart) part;
String value = paramPart.getStringValue();
l_paramList=l_paramList+name.toUpperCase()+"="+value+"&";
}
}
this.paramList = l_paramList;
}catch(Exception e){
e.printStackTrace();
}
}
public String getFileName() {
return fileName;
}
public InputStream getContent() {
return content; }
public String getParamList() {
return paramList;
}
#########################################################
The methods getFileName() and getParamList() return the appropriate values. How can I capture the content and make sure it's vailable when I call getContent() from a JSP?
Thanks in advance.
John
 
John Vemuvella
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reposting due to no response....
Originally posted by John Vemuvella:
Folks,
I'm trying to get the inputstream from a uploaded file and also trying to grab some hidden parameter values. I'm using the oreilly file upload classes to do the same. The problem is that I'm losing the content when processing proceeds to the next part. The InputStream is getting lost even though I store it in a private variable. I need to be able to hold the value and return it when the appropriate method is called from a JSP. I can get the filename and my paraeter values, but not the file content. The code skeleton follows:
###################################################
private String paramList=null;
private String fileName=null;
private InputStream content=null;
public void getMultiFormContent(HttpServletRequest p_request){
try
{
String l_fileName="";
String l_paramList="?";
MultipartParser mp = new MultipartParser(p_request, 10*1024*1024); // 10MB

// Get file name and content
Part part1;
while ((part1 = mp.readNextPart()) != null)
{
if (part1.isFile())
{
// it's a file part
FilePart filePart = (FilePart) part1;
this.fileName = filePart.getFileName();
if (fileName != null)
{
this.content = filePart.getInputStream();
}
}
}
// Get required parameters
Part part;
while ((part = mp.readNextPart()) != null)
{
if (part.isParam()) {
// it's a parameter part
ParamPart paramPart = (ParamPart) part;
String value = paramPart.getStringValue();
l_paramList=l_paramList+name.toUpperCase()+"="+value+"&";
}
}
this.paramList = l_paramList;
}catch(Exception e){
e.printStackTrace();
}
}
public String getFileName() {
return fileName;
}
public InputStream getContent() {
return content; }
public String getParamList() {
return paramList;
}
#########################################################
The methods getFileName() and getParamList() return the appropriate values. How can I capture the content and make sure it's vailable when I call getContent() from a JSP?
Thanks in advance.
John

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!