aspose file tools*
The moose likes Servlets and the fly likes SocketPermissions on http Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SocketPermissions on http" Watch "SocketPermissions on http" New topic
Author

SocketPermissions on http

ken brooks
Greenhorn

Joined: Sep 09, 2001
Posts: 5
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();
%>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SocketPermissions on http
 
Similar Threads
closing streams
Applet and Servlet communication
Connection in servlets
access denied java.net.SocketPermission
URLConnection question, Posting