Search code examples
javajspstruts2tagsstruts-1

How to convert Struts1.0 tag ResponseUtils method write to Struts2


I am working on converting a Struts 1 site to Struts 2, not easy task as everything have changed from one framework to the next.

I was hoping someone has used or know about the org.apache.struts.util.ResponseUtils specifically the write method. We are using Struts 1.0 and we are currently using this line in the code:

 ResponseUtils.write(pageContext, results.toString());

Has anyone seen this tag? use this tag? and then convert it to Struts 2?

I have searched online and found some good tutorials and I am also reading "Struts2 in Action" which I saw recommended here in other post. But, very few sites or posts talk about specific tags.

I will appreciate any advice or hint that can let me to the path of success.


Solution

  • Create your own ResponseUtils with the method

    public void write(PageContext pageContext, String text)
            throws JspException {
    
        JspWriter writer = pageContext.getOut();
    
        try {
            writer.print(text);
    
        } catch (IOException e) {
            throw new JspException(e);
        }
    
    }