• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

JSP Transformer Error with j_security_check

hi everyone,

This below JSP code is working fine without j_security_check, once I apply FORM based j_security_check the output is not been produce. May be its treating URL HTTPURL connection .... as new resource from output and may be excepting login user/pass again ?? If that is so why not redirecting me to error.html. May be I'm wrong.

This is my "/resource/GetResourceHierarchy" servlet which gives DOM XML as output. Is there any alternative way I can try the below code.

<%  
try {    
   StringBuffer reqURL = request.getRequestURL();
   String contextURL = reqURL.substring(0,reqURL.lastIndexOf(request.getServletPath()));    
   URL url = new URL(contextURL + "/resource/GetResourceHierarchy");        
   HttpURLConnection conn = (HttpURLConnection)url.openConnection();            
   conn.setDoInput(true);                
   TransformerFactory tFactory = TransformerFactory.newInstance();
      ServletContext context = getServletContext();
   InputStream is = context.getResourceAsStream("/stylesheets/LiveResourceTree.xsl");
   Transformer transformer = tFactory.newTransformer(new StreamSource(is) );
   transformer.transform(new StreamSource(conn.getInputStream()), new StreamResult(out));

} catch (Exception ex) {out.println( ex.toString() );}
%>

If you have better simple code pls let me know how to do transformer over.
"/resource/GetResourceHierarchy" [THIS IS SERVLET WHICH GIVES DOM XML OUTPUT]
"/stylesheets/LiveResourceTree.xsl" [THIS IS STYLE SHEET]

rEGARDS,
hYD
0
princehyderabad
Asked:
princehyderabad
1 Solution
 
sompol_kiatkamolchaiCommented:
What is the output after login?
0
 
KuldeepchaturvediCommented:
Are you getting any type of error or exception??
0
 
princehyderabadAuthor Commented:
I think I got the answer, since j_security_check is there, when I try

 URL url = new URL(contextURL + "/resource/GetResourceHierarchy");        
   HttpURLConnection conn = (HttpURLConnection)url.openConnection();            
   conn.setDoInput(true);                

browser reconize this as external request and not allowing. So I hv change the above jsp code to as:
<%  
try {  
   ServletContext context = getServletContext();
   Document doc = (Document)request.getAttribute(id);
   if (doc == null) {
               System.out.println("Document is null");
   }
      System.out.println("Context jsp name: " + id);
   TransformerFactory tFactory = TransformerFactory.newInstance();
   InputStream is = context.getResourceAsStream("/stylesheets/_Admin.xsl");
   Transformer transformer = tFactory.newTransformer(new StreamSource(is));
   Source source = new DOMSource(doc);
   transformer.transform(source, new StreamResult(out));

} catch (Exception ex) {out.println( ex.toString() );}
%>

I GOT THE ANSWER !!!!!!!!!!!!!!!!!!!!!!!
0
 
ee_ai_constructCommented:
Question answered by asker or dialog valuable.
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now