my dog learned polymorphism*
The moose likes XML and Related Technologies and the fly likes passing variable value in xsl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "passing variable value in xsl" Watch "passing variable value in xsl" New topic
Author

passing variable value in xsl

vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Hello,

I am having a weird problem. I have a xsl and I need to call a servlet to get a value and use that value to call a java class for further processing. How can I do that? I have developed some code (which is bad), but I am struck on passing the servlet value as a parameter to java class.

Here is my code




Am I going in the right way? Is there any other alternate/better solution for this.


Any help is appreciated.

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't really understand what that is supposed to do.

You have an XSL transformation which is generating HTML. The HTML which it generates contains an <input> element. And
you want to get data from that element??? That doesn't make any sense at all. The element doesn't contain any
data. When the HTML is rendered by the browser and the user looks at the form, the user might key something into
the element at that point, but that happens long after this transformation has finished.

And you want to "call a servlet"? And "get a value"? Does that mean you want to send a request to a server, where
that servlet will be invoked and return a response, and then extract some data from that response? It does help if
you call things by their real names. Also, as before, that form won't send a request until it is in front of a user.

So, I don't know what you are really trying to do there, but whatever it is, that isn't the right way to do it. You should
try to reframe your requirements in terms of XSLT generating HTML, the browser rendering it, the user clicking on
something which sends a request, and so on.
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Thanks Paul,

I know it was an ugly thing. OK, here is what I wanted to do.

I am writing a XSL channel (kind of portlet, this is for SunGard Luminis product), which onload should call a servlet (I need to use a servlet/jsp to get user information as they only have the request object). I need to use this user information to call another java class to get a string that needs to be displayed on the screen.

So as soon as the user login, he will see the result. What would be a good way to do this?

I read that what I am trying to do is not possible now, but is there an alternate for this.

Thanks again.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

vjy chin wrote:which onload should call a servlet

So you'd put some Javascript into the HTML you generate, which would send an AJAX request to that servlet. Nothing to do with XSLT,
that's just the tool for generating the HTML which you have the question about.

But wait... that was what you were doing in the first place. So just keep on doing that, only fix it so that the AJAX response changes
the HTML which you generated.
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Paul,

Thanks for the reply. I need to use the existing xsl, modify it so it gets the user information and gets data from database and display data according to the results which I got from the database.

To get the user information, I need servlet, then I need to access java class.

So the user information will come from AjaxServlet, I do not need to display that. So I might not be able to do what you suggested.

Anyways, I thought of another way of doing it,

1. xsl calling a java class without any parameters
2. call a servlet inside the java class
3. get the person details in servlet and send it to java class
4. use the person details and call the database and get the details and send it back to xsl.

I am struck in step 3. I am sending the value as objectstream and getting as objectstream in the java class, but I get "java.io.StreamCorruptedException: invalid stream header". I have posted this in the I/O forum.

Thanks for your help again Paul.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

vjy chin wrote:I have posted this in the I/O forum.


Good idea, that question does fit better over there.

Although you might consider connecting to the servlet before you process the XSLT, and pass the servlet's response
into the XSLT as a parameter. That seems a bit less convoluted to me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: passing variable value in xsl
 
Similar Threads
Passing values to and from HTML
JS code not working.
Is there something better then event.pageX/Y?
dojo and javascript DOM issue
Need Help With Dynamic text box in JSP