You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcello Savino <Ma...@aldebra.com> on 2007/01/24 11:16:00 UTC

Reading generated html

 
Hi all.
I need to read in a Bean the generated html (i mean the one interpreted
by the browser).
Let me explain further:
In a jsp file i've this piece of code:

[...]
<html:form action="/someAction">
[...]
<jsp:useBean id="myObj" class="util.Test" scope="request">
	<jsp:setProperty name="myObj" property="html"
value="<%=request%>"></jsp:setProperty>
</jsp:useBean>
[...]
</html:form>
[...]

This is the bean:

package util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;;
public class Test {

	public Test(){
	}
	public void setHtml(HttpServletRequest request){
		StringBuffer HTMLStr=new StringBuffer("");		
		ServletInputStream content=request.getInputStream();
		BufferedReader br = new BufferedReader(new
InputStreamReader(content));
		HTMLStr.append(br.readLine());
	}
}

But i get no HTML string, always get a null string ! 
I suppose the bean method is invoked before tha page was rendered, but i
can figure out how invoke the bean after.
Even an alternative approach will be intersting for me.

Any help will be greatly appreciated
Thanks in advance

Marcello Savino
ALDEBRA S.p.A. 
tel.  0461302441

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Reading generated html

Posted by Kandelwal Abhishek <Ab...@acs-hro.com>.
Hi dear,

I guess the method setHtml(HttpServletRequest request) is not called
because the data u r setting from JSP is of type String but the bean
method parameter takes HttpServletRequest. So change the parameter type
to String instead of HttpServletRequest. 

Hope it will solve the problem.

Thanks & Regards
Abhishek Khandelwal


-----Original Message-----
From: Marcello Savino [mailto:Marcello.Savino@aldebra.com] 
Sent: Wednesday, January 24, 2007 5:16 AM
To: Struts Users Mailing List
Subject: Reading generated html

 
Hi all.
I need to read in a Bean the generated html (i mean the one interpreted
by the browser).
Let me explain further:
In a jsp file i've this piece of code:

[...]
<html:form action="/someAction">
[...]
<jsp:useBean id="myObj" class="util.Test" scope="request">
	<jsp:setProperty name="myObj" property="html"
value="<%=request%>"></jsp:setProperty>
</jsp:useBean>
[...]
</html:form>
[...]

This is the bean:

package util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;;
public class Test {

	public Test(){
	}
	public void setHtml(HttpServletRequest request){
		StringBuffer HTMLStr=new StringBuffer("");		
		ServletInputStream content=request.getInputStream();
		BufferedReader br = new BufferedReader(new
InputStreamReader(content));
		HTMLStr.append(br.readLine());
	}
}

But i get no HTML string, always get a null string ! 
I suppose the bean method is invoked before tha page was rendered, but i
can figure out how invoke the bean after.
Even an alternative approach will be intersting for me.

Any help will be greatly appreciated
Thanks in advance

Marcello Savino
ALDEBRA S.p.A. 
tel.  0461302441

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org