Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SocketPermissions on http

 
ken brooks
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code, all i'm trying to do is make a connection to
livejournal.com on port 80 and POST something and read the reply.
I'm getting:
javax.servlet.ServletException: access denied (java.net.SocketPermission www.livejournal.com resolve)
or if i put in the ip instead of www.livejournal.com
i get:
javax.servlet.ServletException: access denied (java.net.SocketPermission 66.150.15.150:80 connect,resolve)
What needs to be done to fix this? Server side? Something in my code (which i haven't messed with in a month, so i may have been tinkering and left it unworkable).
Thanks
Code Below:
<%@ page import="java.net.*,java.io.*" %>
<%
String modeString = new String("");
String usernameString = "fakeuser";
String passwordString = "fakepass";
modeString = "mode=login&user=" + usernameString + "&password=" + passwordString;

URL url = new URL("http://www.livejournal.com/cgi-bin/log.cgi");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Host", "www.livejournal.com");
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-length", Integer.toString(modeString.length()));
connection.setDoOutput(true);
out.println(connection.getPermission());
PrintWriter outserver = new PrintWriter(connection.getOutputStream());
outserver.print(modeString);
outserver.close();
out.println(connection.getResponseCode());
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
out.println(inputLine);
in.close();
%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic