Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

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

Posted on 2003-11-03
5
Medium Priority
?
244 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
What monsters are hiding in your child's room? In this article I will share with you a tech horror story that could happen to anyone, along with some tips on how you can prevent it from happening to you.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 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