|
»
« Return to Thread: HttpServletRequest.getInputStream within an Element
HttpServletRequest.getInputStr eam within an Element
Hi all,
Has anyone tried using HttpServletRequest.getInputStream() from within
an Element? The web services elements, specifically the
WebserviceHessian element, refer to it, but I can't seem to actually
read any data from it myself.
Here's my code (also available at http://rifers.org/paste/show/8652):
==========================================
public class ReportData extends Element {
Logger logger = Logger.getLogger(this.getClass().getName());
public void processElement()
{
try {
HttpServletRequest request = getHttpServletRequest();
logger.info("getMethod()=["+getMethod()+"]");
// This works: the content is a POST
int max_length_of_data = request.getContentLength();
// This works: the content length seems to be correct.
logger.info("max_length_of_data: ["+max_length_of_data+"]");
ServletInputStream httpIn = request.getInputStream();
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[1000];
int count = 0;
try {
// No data is ever read; even for
// five attempts over 5 seconds...
for( int i =0; i<=5; ++i ) {
count = httpIn.read(buf, 0, 1000);
logger.info("count=["+count+"]");
if( count > -1 ) {
String input = new String(buf,0,count);
sb.append(input);
}
Thread.sleep(1000);
}
} catch( Exception e ) {
logger.log(Level.INFO,e.getMessage(),e);
}
logger.info(""+sb.toString());
} catch (Exception e1) {
logger.log(Level.INFO,e1.getMessage(),e1);
}
return;
}
public boolean prohibitRawAccess()
{
return false;
}
}
==========================================
All the best,
Josh
--
Joshua Hansen
Up Bear Enterprises
(541) 760-7685
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---
« Return to Thread: HttpServletRequest.getInputStream within an Element
| Free embeddable forum powered by Nabble | Forum Help |
