|
|
|
Supreme Being
      
модератор
Last Login: 10.03.2008 23:02
Сообщ.: 2 077,
Visits: 21 402
|
|
У меня проблема с SecurityException я пытаюсь сделать апплет-сервлет коннекшн для получения данных из БД но из-за SecurityException не могу законнетаться с сервлетом.Помогите если можно...
Спасибо
|
|
|
|
|
Forum Member
      
участник
Last Login: 24.06.2004 20:23
Сообщ.: 32,
Visits: 353
|
|
Может быть у тебя сервлет и аплет на разных компах сидят ?
|
|
|
|
|
Forum Member
      
участник
Last Login: 24.06.2004 20:23
Сообщ.: 32,
Visits: 353
|
|
Может быть у тебя сервлет и аплет на разных компах сидят ?
|
|
|
|
|
Supreme Being
      
модератор
Last Login: 10.03.2008 23:02
Сообщ.: 2 077,
Visits: 21 402
|
|
да нет на одном проблема во-первых с браузерами но если я запускаю апплет через appletwiewer то запрос апплета проходит но ответа от сервлета нет.
часть кода сервлета
public void service(HttpServletRequest request,
HttpServletResponse response)throws
ServletException,IOException
{
System.out.println("hey it's me");
try
{
ObjectInputStream ois =
new ObjectInputStream(request.getInputStream());
Order order =(Order)ois.readObject();
System.out.println("here " + ois);
Order ord = connect_to();
System.out.println("And here " + ord);
response.setContentType("application/octet-stream");
ObjectOutputStream oos =
new ObjectOutputStream(response.getOutputStream());
oos.writeObject(ord);
oos.flush();
oos.close();
}
catch(Exception e)
{
System.err.println(e);
}
}
часть кода апплета
public void writeRequest(URLConnection c,Order value)
{
try
{
c.setUseCaches(false);
c.setRequestProperty("CONTENT_TYPE","application/octet-stream");
c.setDoInput(true);
c.setDoOutput(true);
ObjectOutputStream os =
new ObjectOutputStream(c.getOutputStream());
System.err.println("Writing data");
System.err.println("Am I writng request to " + c + " ?");
os.writeObject(value);
System.err.println("Still Writing data");
os.flush();
os.close();
System.err.println("Finished to write request");
}
catch(NullPointerException ne)
{
System.out.println("Error " + ne);
}
catch(IOException ie)
{
System.err.println("inputoutputexception " + ie.getMessage());
}
}
public Order readResponse(URLConnection conn)
{
System.out.println("Opening connection to read 1a "+conn);
Order order = null;
System.out.println("Opening connection to read 2 "+conn);
try
{
InputStream in = conn.getInputStream();
System.err.println("Loading data1");
ObjectInputStream is = new ObjectInputStream(in);
System.err.println("Loading data2");
order = (Order)is.readObject();
is.close();
}
catch (SecurityException se)
{
System.err.println("security exception " + se.getMessage());
}
catch(IOException ie)
{
System.err.println("read response ioexception " + ie.getMessage());
}
catch(ClassNotFoundException ce)
{
System.err.println(ce.getMessage());
}
|
|
|
|
|
Forum Member
      
участник
Last Login: 24.06.2004 20:23
Сообщ.: 32,
Visits: 353
|
|
А класс Order у тебя Serializable или Externalizable ?
В Сервлете Exception не выдаётся ?
Стек Exception можешь прислать ?
|
|
|
|
|
Supreme Being
      
модератор
Last Login: 10.03.2008 23:02
Сообщ.: 2 077,
Visits: 21 402
|
|
Order конечно Serializable а в сервлете никаких Exception нет Exception возникает в апплете в методе readResponse() вот в этой строчке
InputStream in = conn.getInputStream();
и возбуждается IOException на url сервлета
|
|
|
|
|
Forum Member
      
участник
Last Login: 24.06.2004 20:23
Сообщ.: 32,
Visits: 353
|
|
|
|
|
|
Forum Member
      
участник
Last Login: 24.06.2004 20:23
Сообщ.: 32,
Visits: 353
|
|
Проверь ещё что у веб сервера разрешено чтение с этой виртуальной директории..
|
|
|
|