I want to send an object as applet param from my jsp page which embeds the applet.and how do i receive the object inside the applet class.
This is my code :
my servlet snippet
byte unsignedbytearray=new FiletoByteArray().receiveObject(filename);
showapplet..jsp (which has embedded an applet )
<%@ page language="java" %>
byte bytearray=(byte)request.getAttribute("fileobject");//byte array received from some servlet view
System.out.println("array object received Size is "+bytearray.length); //this gives correct output : "array object received Size is 1787264"
<jsp:plugin type="applet" code="demoapplication.ControlFrame.class"
width="700" height="550" codebase="context" archive="file.jar,itextpdf-5.2.1.jar,bctsp-jdk16-1.46.jar,bcprov-jdk16-1.46.jar">
<jsp:param name="file" value="<%=bytearray.toString()%>" />
<p>Unable to load applet</p>
my Controlframe.class snippet receiving the param
System.out.println("received at applet size: "+unsignedPdf.length()); //This Gives strange output :received at applet size:10
Can jsp send an object as param??
nausheen fatma wrote:I ther a way where i could use jsp getproperty to receive the byte array and then send it as param to applet??? My project demands that i should avoid creating a URL connection from applet,and receive byte array directly from servlet
Two possibilities to get you moving :-
1) Base64 or Hex or ASCII85 encode the byte array and pass that as a parameter.
2) Use something like XStream to generate an XML serialization of the object and pass that as a parameter. Some form of encoding might still be required.
Though both these might work I would first of all find out why "my project demands that i should avoid creating a URL connection from applet,and receive byte array directly from servlet" is a requirement? This seems a little strange.
nausheen fatma wrote:Hmmn.......could you provide me some link for the above solutions ,as i am new to applets..
I have already done that way, and my project lead somehow wants to get the bytearray as parameter to applet..Donno why ..