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 68609
In Process

The Archive Base Latest Questions

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

What I am is trying to do is the following. Pass two parameters to

  • 0

What I am is trying to do is the following.

Pass two parameters to a URL

  • type
  • doc_id

Once they are passed to the JSP via the URL I want to apply a the type template to the doc_id xml.

So if the type is 001 then the 001.xsl is applied to doc_id.xml. The output of this I don’t want stored in a file but rather directley outputed to the browser.

How would I go about doing this using XALAN and a JSP page?

  • 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. 2026-05-10T19:26:36+00:00Added an answer on May 10, 2026 at 7:26 pm

    I would suggest that this type of code goes in a servlet rather than a JSP page. If you have some specific constraint that requires a JSP then the code could be modified to work on a JSP page.

    The XALAN site has a nice example using a servlet which I’ll copy here for convenience: The original can be found here. In this example they hard coded the names of the xsl and xml files but that is easy to modify to use your file names generated as you described. The important thing is that the generated output is streamed to the browser.

    public class SampleXSLTServlet extends javax.servlet.http.HttpServlet {      public final static String FS = System.getProperty('file.separator');      // Respond to HTTP GET requests from browsers.      public void doGet (javax.servlet.http.HttpServletRequest request,                  javax.servlet.http.HttpServletResponse response)                  throws javax.servlet.ServletException, java.io.IOException    {      // Set content type for HTML.      response.setContentType('text/html; charset=UTF-8');          // Output goes to the response PrintWriter.      java.io.PrintWriter out = response.getWriter();      try      {           javax.xml.transform.TransformerFactory tFactory =             javax.xml.transform.TransformerFactory.newInstance();         //get the real path for xml and xsl files.         String ctx = getServletContext().getRealPath('') + FS;                 // Get the XML input document and the stylesheet, both in the servlet        // engine document directory.        javax.xml.transform.Source xmlSource =              new javax.xml.transform.stream.StreamSource                          (new java.net.URL('file', '', ctx+'foo.xml').openStream());        javax.xml.transform.Source xslSource =              new javax.xml.transform.stream.StreamSource                          (new java.net.URL('file', '', ctx+'foo.xsl').openStream());        // Generate the transformer.        javax.xml.transform.Transformer transformer =                           tFactory.newTransformer(xslSource);        // Perform the transformation, sending the output to the response.       transformer.transform(xmlSource,                         new javax.xml.transform.stream.StreamResult(out));      }      // If an Exception occurs, return the error to the client.     catch (Exception e)     {        out.write(e.getMessage());        e.printStackTrace(out);         }     // Close the PrintWriter.     out.close();    }   } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass two values to the following controller action using jQuery
I'm trying to write a function that adds two matrices to pass the following
How can I pass two querysting parameters in URL routing using ASP.NET 4.0? I
I'm trying to pass the following String to a PreparedStatement : private static final
I have the following javascript class which I am trying to pass to an
The following is the custom class, whose object I am trying to pass: package
I am trying to pass a value between two pages. However on my target
I'm trying to pass parameter of short type to C++ unmanaged function imported from
I have the following program where two variables are to be passed by reference
I am trying to write a function that takes two matrices as parameters and

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.