Re: Programmatically Requesting a Jetspeed Page

2004-05-29 Thread Raphaël Luta
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:


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 - [EMAIL PROTECTED]
Apache Jetspeed - Enterprise Portal in Java
http://portals.apache.org/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Programmatically Requesting a Jetspeed Page

2004-05-25 Thread Jason Shindler
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