开发者

Syntax error on token "setRedirectStrategy", = expected after this token

I am getting following error:- Syntax error on token "setRedirectStrategy", = expected after this token What does this means?? And how can i resolve it.

<%@ page language="java" import="org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.methods.HttpGet,org.apache.http.protocol.HttpContext,org.apache.http.impl.client.DefaultHttpClient,org.apache.http.Ht开发者_StackOverflowtpResponse,org.apache.http.HttpRequest,java.io.OutputStream,java.net.HttpURLConnection,java.net.URL,java.util.Collection,org.apache.commons.httpclient.Credentials,org.apache.commons.httpclient.auth.AuthenticationException,org.apache.commons.httpclient.auth.MalformedChallengeException,org.apache.commons.httpclient.params.DefaultHttpParams,org.apache.commons.httpclient.params.HttpParams,org.apache.commons.httpclient.auth.AuthScheme,org.apache.commons.httpclient.auth.AuthPolicy,org.apache.commons.httpclient.HttpClient,org.apache.commons.httpclient.UsernamePasswordCredentials,org.apache.commons.httpclient.auth.AuthScope,org.apache.commons.httpclient.methods.GetMethod,org.w3c.dom.*,javax.xml.parsers.DocumentBuilder,javax.xml.parsers.DocumentBuilderFactory,java.net.*,java.io.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%
String a_Url = request.getParameter( "url" ) ;

URL url = new URL (a_Url);
String encoding = new String(
         org.apache.commons.codec.binary.Base64.encodeBase64   
            (org.apache.commons.codec.binary.StringUtils.getBytesUtf8("test:test"))
          );


HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setRequestProperty  ("Authorization", "Basic " + encoding);
InputStream content = (InputStream)connection.getInputStream();
BufferedReader in   = 
    new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
   out.println(line);
}

%>
<%!

HttpClient client = new HttpClient();
client.setRedirectStrategy(new DefaultRedirectStrategy() {
            public boolean isRedirected(HttpRequest hr, HttpResponse hr1, HttpContext hc) {
                if (hr1.getStatusLine().getStatusCode() == 302) {
                    return true;
                }
                return false;
            }

         public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) {
                HttpGet get = null;
                try {

                    String newLocation = "" + response.getFirstHeader("Location");
                    newLocation = newLocation.substring(newLocation.indexOf("Location:")+10);
                    get = new HttpGet(newLocation);


                } catch (Exception ex) {
                    System.out.println(ex.getLocalizedMessage());
                }
                return get;
            }
        });


%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜