|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Sep 2002
Città: Monza
Messaggi: 598
|
[html + java] codifica chiocciolina (@) o altro?
ciao amici,
ho un problema: ho una form html del tipo: <FORM METHOD=POST ENCTYPE="multipart/form-data" ACTION="http://............. NAME=........> E-mail: <INPUT TYPE=TEXT NAME=email > </form> in un sito che sto analizzando. Sto realizzandoun tool java per interrogare la form automaticamente. il problema è che il sistema mi dice che: Badly formed E-mail Address mentre se compilo la form a mano tutto funziona. Sto usando il seguente pezzo di codice Codice:
File prediction =new File("nome");
File FileProperties = new File(prediction,"MODEL.properties");
FileWriter outFileProperties = new FileWriter(FileProperties);
PrintWriter FileP= new PrintWriter(outFileProperties) ;
FileP.println(http);
FileP.println(seq);
FileP.close();
String fileName = "MODEL.properties";
Properties props = new Properties();
FileInputStream in = new FileInputStream(fileName);
props.load(in);
URL url = new URL(props.getProperty("URL"));
props.remove("URL");
String r = doPost(url, props);
File outputFile = new File("MODEL.html");
FileWriter out2 = new FileWriter(outputFile);
PrintWriter out1= new PrintWriter(out2) ;
out1.println(r);
out1.close();
Codice:
public static synchronized String doPost(URL url, Properties nameValuePairs)
throws IOException
{
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
PrintWriter out= new PrintWriter(connection.getOutputStream());
Enumeration enum2 = nameValuePairs.keys();
while (enum2.hasMoreElements()){
String name = (String)enum2.nextElement();
String value = nameValuePairs.getProperty(name);
char ch;
if (enum2.hasMoreElements()) ch = '&'; else ch = '\n';
out.print(name + "="
+ URLEncoder.encode(value,"UTF-8") + ch);
}
out.close();
BufferedReader in;
try{
in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
}
catch (FileNotFoundException exception){
InputStream err= ((HttpURLConnection)connection).getErrorStream();
if (err == null)
throw exception;
in = new BufferedReader(new InputStreamReader(err));
}
StringBuffer response = new StringBuffer();
String line;
while ((line = in.readLine()) != null)
response.append(line + "\n");
in.close();
return response.toString();
}//fine doPost
Codice:
URL=http://www.qualcosa._submit.cgi [email protected]'
__________________
Nunc est bibendum |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 17:54.



















