?
Solved

Getting an XML doc from a Struts Action class into a JSP

Posted on 2003-11-03
5
Medium Priority
?
242 Views
Last Modified: 2010-04-01
Using Struts, I have this Action Class

    public static final String SESSION_USER_PROFILE = "USERPROFILE_SESSION_KEY";
    public static final String REQUEST_FORPARTYID = "forPartyId";
    public static final String REQUEST_ACTION_SUBMIT = "submit";
    public static final String FORWARD_SUCCESS = "success";
    public static final String FORWARD_SUCCESSXML = "SuccessXML";
    public static final String FORWARD_ERRORXML = "ErrorXML";
    public static final String REQUEST_ACCOUNTSXML = "accountsXML";

    public ActionForward process (ActionMapping actionMapping,
                                  ActionForm actionForm,
                                  HttpServletRequest httpServletRequest,
                                  HttpServletResponse httpServletResponse) {

        ActivityAccountsActionForm frm = (ActivityAccountsActionForm) actionForm;
        HttpSession session = httpServletRequest.getSession();
        UserProfile up = (UserProfile)session.getAttribute(SESSION_USER_PROFILE);

        ActivityMgmtHelper helper = new ActivityMgmtHelper();
        ActivityMgmtXml helperXml = new ActivityMgmtXml();

        int forPartyId = Integer.parseInt(httpServletRequest.getParameter(REQUEST_FORPARTYID));
        frm.setForPartyId(forPartyId);
        helper.requestActivityAccountData(frm, up);

        frm.setActivityAccountsXML(helperXml.getActivityAccountsXml(up, frm.getPortfolio()));
        session.setAttribute(REQUEST_ACCOUNTSXML, frm.getActivityAccountsXML());

            return actionMapping.findForward(FORWARD_SUCCESS);
        }

and this JSP

<%@ page language="java" %>
<%= session.getAttribute("accountsXML") %>


and I commonly use these tag libraries

<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>




The problem:
frm.getActivityAccountsXML() returns an XML document that I use client-side. This document can be quite large (I've seen 600k and larger WILL happen).  I do not want to pass this big XML doc through the session (as above) or as a request attribute (which would be better than the session object, I know...).

I tried using c:out, but it freaking HTMLencodes the XML doc...needless to say, I get a parse error.

Points go to whomever can tell me how I get the XML doc from frm.getActivityAccountsXML() in the JSP without passing the value through the session or request objects, without HTMLencoding it, and using the tag libs above (or directly from the ActivityAccountsActionForm class) and using the struts model like seen above.


I'm too picky... ;-)
0
Comment
Question by:mgeiser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
kotan earned 1000 total points
ID: 9674861
In the Action, straight away output the buffer without go through jsp

   response.setContentType("text/xml");
   PrintWriter pw = response.getWriter();
   pw.print(frm.getActivityAccountsXML());

so the Action return null;
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9675598
Don't you think you have too much open questions to post a new one?
>> I'm too picky... ;-)
me too ;-)
0
 

Author Comment

by:mgeiser
ID: 10858838
The points will go to Kotan for a great answer that I have used...

I'm surprised that no one mentioned <c:out value="${ActivityAccountsActionForm.activityAccountsXML}" escapeXml="false"/>



0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question