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

  • SEARCH
  • Home
  • 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 6719441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:05:36+00:00 2026-05-26T09:05:36+00:00

I have a FrontController that returns Representation in a homemade REST framework. I have

  • 0

I have a FrontController that returns Representation in a homemade REST framework. I have some XmlRepresentation, JsonRepresentation and I would like now a JspRepresentation.
A UserJspRepresentation could be for exemple a page or a fragment that represents the User. A Jsp would then be a Template that may use

I could do some forward/include stuff, but I would like something more isolated, and get the result as an object. The forward() method returns void.

Something like :

HttpServletRequest request = getHttpServletRequest();
User user = getUser();
request.setAttribute("user", user); // The Jsp will be aware of the user
JspRepresentation representation = new JspRepresentation(request, "userPage.jsp");
String result = representation.toString();// this is hard to get the displayed page !!!

The question is : How to get the Jsp Page as a String object?

For now I can only consider using a java client, which is not lightweight… I have also looked in the Jasper API, but found nothing clear.

  • 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-26T09:05:37+00:00Added an answer on May 26, 2026 at 9:05 am

    You can’t. JSP is not a template engine. It’s just a view technology. You’re looking for a template engine like Velocity, Freemarker, Sitemesh, etc.

    Best what you can do with JSPs is to send a fullworthy HTTP request to its concrete URL yourself.

    InputStream input = new URL("http://localhost:8080/context/userPage.jsp").openStream();
    // ...
    

    You only can’t pass request attributes to it. You can however put it in the session and let the JSP retrieve it from there. You only need to send the JSESSIONID cookie along:

    URLConnection connection = new URL("http://localhost:8080/context/userPage.jsp").openConnection();
    connection.setRequestProperty("Cookie", "JSESSIONID=" + session.getId());
    InputStream input = connection.getInputStream();
    // ...
    

    Alternatively, you can also just forward the request to the JSP “the usual way” instead of getting its HTML output as String and writing it to the response yourself. This way the JSP will do its job of generating the HTML based on the current request and sending it to the response without the need to collect that HTML and write to the response yourself.

    request.getRequestDispatcher("/WEB-INF/userPage.jsp").forward(request, response);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a c# library project, that i configured using nhibernate, and I like
I have a larger application with a Frontcontroller in php that handles incoming ajax
I have a controller that extends Zend_Controller_Action. It contains some actions that I need
I have an auth module, and would like to keep a Login form in
I have some dilemma about controller usage. Like usualy, router (dispatcher or front controller)
I am creating an MVC application framework, using only libararies and components that I
I am using Zend Framework, I have a layout.phtml which renders navigation.phtml. How can
I have a servlet that is used for many different actions, used in the
I have a CI application that uses .htaccess for URL routing. My basic setup
If I have a directory structure like this: - index.php - public - img

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.