Solved

JSP Transformer Error with j_security_check

Posted on 2004-09-13
5
439 Views
Last Modified: 2011-08-18
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
Comment
Question by:princehyderabad
5 Comments
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12055125
What is the output after login?
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 12062805
Are you getting any type of error or exception??
0
 

Author Comment

by:princehyderabad
ID: 12067385
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
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12414671
Question answered by asker or dialog valuable.
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now