Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 875481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:16:38+00:00 2026-05-15T11:16:38+00:00

I have a JSP page that renders a block of HTML. In normal usage,

  • 0

I have a JSP page that renders a block of HTML. In normal usage, I load the contents of the JSP using AJAX (specifically, using jQuery.load()) and insert it into the page. Now, I need to be able to load this block of HTML into a different domain, which means the same-source restrictions won’t allow me to use “normal” AJAX.

This block gets included in multiple places, some of which will be on the same domain and some of which will be on alternate domains. I would prefer to have it continue to work the way it works currently unless a specific parameter is passed (in all likelihood, that would be the callback function that is passed for JSONP support).

My conceptual solution (thus far) is to output JSONP, with a single KEY/VALUE pair, having the complete HTML output as the VALUE.

The PROBLEM: I can’t find any way to get the buffered output that is waiting to be sent when the JSP finishes rendering and modify it (in this case, to replace actual new lines with “\n”. Without that, I get an Unterminated String Literal error when my JSONP function hits the first new line.

EXAMPLE:

<%@page contentType="text/html"%>
<%
    String callback = request.getParameter("callback");
%>
<% if(callback != null) { %>
    // JSONP Function call, defining Key/Value Pair
    // New lines break because JavaScript strings cannot cross lines
    <%= callback %>({"key":'
<% } %>

<div id="my_content">
    ...
</div>

<% if(callback != null) { %>
    '}) // End of JSONP Function Call
<% } %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:16:39+00:00Added an answer on May 15, 2026 at 11:16 am

    The JSON Taglib library should do what you need. I haven’t used it myself, but it’s the right approach to the problem, something like this:

    <%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %>
    
    <json:object>
    <json:property name="key">
    
    <div id="my_content">
        ...
    </div>
    
    </json:property>
    </json:object>
    

    You’ll probably have to wrap the JSONP parenthesis around the result yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSP page that renders, and calls a Web service to load
I have a JSP page that creates a treeview using jQuery treeview plugin. Now
I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that
I have a functional JSP page that accepts URL parameters and updates a table
What I have: I have a generic JSP page that is used throughout my
I have a JSP application that connects to oracle on the log in page.
I have jsp page that contains <span class=requiredFieldsMessageAsterix>*</span> I use a jsp include to
I have a .jsp page that the user loads directly. The request it with
I have a JSP, say view.jsp , that's using the basic Liferay search container
I have a dynamic page (say myFlashContainer.jsp) which renders different Flash content based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.