[Thread Prev][Thread Next][Index]
Re: LAS Server in dynamik php website
Joerg,
As you may have gathered from the message, when the opening page is
delivered for the first time, the servlet attempts to set a cookie by
sending a redirect to the browser. After the cookie has been set and
the servlet can retrieve the cookie, the actual content is delivered to
the browser.
If you want load the opening page via PHP, you'll probably need to
manage the interaction with the servlet in PHP to obtain the session
cookie and use PHP to deliver the cookie to the browser. Here is a Perl
example that does something similar. Of course, you can't just throw
the cookie away in you PHP program, you'll have to send it on to the
browser.
Roland
---------
#! /usr/bin/perl -w
# get_las_page.pl
# program to get LAS servlets/dataset response and print to file.
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Cookies;
# Question: is this a good name and path? presumably $lasroot/bin/
my $cookie_file = 'read_las_cookies.txt';
#
# Read the URL from the command line.
# Note: the configure script sets this up to access the tomcat URL directly.
# If you use a connector or a proxy config to pass the request from Apache
# to tomcat you may want to use the apache URL instead
if ($#ARGV < 1) {
print STDERR "usage: get_las_page.pl LAS_URL output_file\n";
}
my $url = shift @ARGV;
my $output_file = shift @ARGV;
my $ua = new LWP::UserAgent;
$ua->cookie_jar(HTTP::Cookies->new(file => "$cookie_file", autosave => 1));
# first request
my $request = HTTP::Request->new(GET => $url);
my $response = $ua->request($request);
# deal with LAS cookie check response (sends back '302 - Temporarily Moved'
# message and cookie check URL
while ($response->{_rc} eq '302'){
$url=${$response->{_request}->{_uri}};
$request = HTTP::Request->new(GET => $url);
$response = $ua->request($request);
}
if ($response->is_success) {
unlink $cookie_file;
open (OUT,">$output_file");
my $stuff = $response->content;
print OUT "\n$stuff\n";
close OUT;
}else{
my $status_line = $response->status_line;
die "get_las_page.pl failed, server response was: $status_line\n";
}
Joerg Franke wrote:
Hi,
I built a website with a dynamical structure using tables and php
instead of frames and html. When I try to include the LAS-Server in my
"mainframe" table cell:
<?php
include 'http://<servername>:8080/las/servlets/dataset';
?>
this error message appears:
"Cookies required
The Live Access Server provides access to geophysical and
environmental scientific data. If you wish to access this data,
however, your browser must support cookies. "
although Cookies are enabled of cause.
If it is not possible that way, is there another easy way to embed the
LAS-Server into my php webpage?
Cheers
Jörg
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement