Originariamente inviato da br1
Il problema e' lato server.
ciao
si...quindi? Questo è il codice Jsp che ho provato lato server:
codice:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"
import="java.io.BufferedReader,
java.io.InputStreamReader,
java.io.IOException,
java.io.InputStream,
java.net.MalformedURLException,
java.net.URL,
javax.servlet.*,
java.net.URLConnection"
%>
<%!
private String contentURL;
public static final String CONTENT_URL_NAME = "contentURL";
%>
<%
// get the url through the request:
if (contentURL == null) {
contentURL = (String)request.getAttribute(CONTENT_URL_NAME);
if (contentURL == null)
contentURL = (String)request.getParameter(CONTENT_URL_NAME);
}
if (contentURL == null)
throw new ServletException("A content URL must be provided, as a " + CONTENT_URL_NAME + " request attribute or request parameter.");
URL url = null;
try {
// get a connection to the content:
System.out.println(contentURL);
url = new URL(contentURL);
URLConnection urlConn = url.openConnection();
// show the client the content type:
String contentType = urlConn.getContentType();
response.setContentType(contentType);
// get the input stream
InputStream in = urlConn.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
char[] buffer = new char[1024];
String contentString = "";
String tmp = br.readLine();
do
{
contentString += tmp + "\n";
tmp = br.readLine();
}
while (tmp != null);
out.flush();
out.close();
}
catch (MalformedURLException me) {
// on new URL:
throw new ServletException("URL: '" + contentURL + "' is malformed.");
}
catch (IOException ioe) {
// on opne connection:
throw new ServletException("Exception while opening '" + contentURL + "': " + ioe.getMessage());
}
catch (Exception e) {
// on reading input:
throw new ServletException("Exception during proxy request: " + e.getMessage());
}
%>
lo script fa una GET invece a me serve che faccia una POST...come potrei fare? avete qualche script di un proxy che faccia una POST?