code JSP:Désérialise un objet Java provenant d'une page JSP?
<%
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ObjectOutputStream output = new ObjectOutputStream(stream);
output.writeObject(new BigDecimal("111"));
output.flush();
output.close();
response.getOutputStream().write(stream.toByteArray());
out.clear();
out = pageContext.pushBody();
%>
code au client, (réponse est un objet de org.apache.http.HttpResponse
)
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
byte[] buff = new byte[1024];
is.read(buff);
ByteArrayInputStream bi = new ByteArrayInputStream(buff);
ObjectInputStream oi = new ObjectInputStream(bi);
Je reçois l'exception:
Exception in thread "main" java.io.StreamCorruptedException: invalid stream header: 3C68746D
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
utilisez-vous sur http ou un autre protocole – shinynewbike
bien sûr, http ...... –
Toute raison d'utiliser JSP au lieu d'un servlet plus simple? – artbristol