You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Jason Shindler <ja...@housing.ufl.edu> on 2004/05/25 15:55:01 UTC

Programmatically Requesting a Jetspeed Page

Hello,
I wish to email the contents of a page from inside of my Jetspeed
portlet. The page requires authentication, so I'm passing the current
session's JSESSIONID as a cookie so my program can be authenticated. For
some reason this is not working:
 
            URL url = new
URL("http://localhost/housing-portal/portal/media-type/html/role/user/pa
ge/default.psml/js_peid/P-fc7f0d2122-10002");
            HttpURLConnection conn = (HttpURLConnection)
url.openConnection();
            conn.setRequestProperty ("Cookie", "JSESSIONID="+
rundata.getSession().getId() + "; path=/housing-portal;");
            conn.setDoOutput(true);
            conn.setUseCaches (false);
            conn.setRequestProperty ("Content-Type", "text/html");
            conn.connect(); 
           
            String inputLine, httpOutput = "";
            DataInputStream  in =(new DataInputStream(url
                    .openStream()));
          
            while ((inputLine = in.readLine()) != null) {
                httpOutput += inputLine;
            }
          
      
The code requests the page, but returns a login screen instead of the
page I want. I believe it is somehow ignoring the cookie, but can't put
my finger on why. Any ideas?
 
Jason Shindler
Network Services
University of Florida, Department of Housing and Residence Education

Re: Programmatically Requesting a Jetspeed Page

Posted by Raphaël Luta <ra...@apache.org>.
Le 25 mai 04, à 15:55, Jason Shindler a écrit :

> Hello,
> I wish to email the contents of a page from inside of my Jetspeed
> portlet. The page requires authentication, so I'm passing the current
> session's JSESSIONID as a cookie so my program can be authenticated. 
> For
> some reason this is not working:
>
<snip code>
>
> The code requests the page, but returns a login screen instead of the
> page I want. I believe it is somehow ignoring the cookie, but can't put
> my finger on why. Any ideas?
>

I'm not sure exactly how you have constructed your email module but I 
would
strongly advise you *against* using sub-HTTP connections to generate 
your
mail messages.

Since you seem ti be able to rely on the user session, your code is 
probably
called during a user request, in which case Jetspeed will have populated
the RunData object with all the necessary context.

Then define a custom velocity template for your mail and in this 
template use
$jetspeed.getPane(pagename). It should work but you will want to save
the Profile stored in rundata before rendering the velocity template 
and restore
it after because $jetspeed.getPane() will set the page globally for the 
request.

Make sure to take a look at

src/java/org/apache/jetspeed/util/template/JetspeedTool.java
webapp/WEB-INF/templates/vm/screens/html/Home.vm

to have a better idea of what you can do with this JetspeedTool (viewed 
as
$jetspeed in Velocity templates)

--
Raphaël Luta - raphael@apache.org
Apache Jetspeed - Enterprise Portal in Java
http://portals.apache.org/


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org