Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

post parameter to jsp from an applet

 
Greg Triant
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all!

I need to post one typical name/value parameter to a jsp, from within an applet. But I also want to be redirected to that jsp. Can this be done???

So far I have done this by passing the parameter in the url (which is a get method) using :

this.getApplet().getAppletContext().showDocument(new URL(http://...myJSP.jsp?id=5))


I also tried to do this by opening a connection to the jsp:


URL myurl = new URL(http://...myJSP.jsp);
URLConnection uc = myurl.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
PrintWriter pw = new PrintWriter(uc.getOutputStream());
pw.println(send);
pw.close();

But how am I supposed to send my parameter AND at the same time pass the browser control to that jsp???
 
Alan Mehio
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
try the blow


// Applet in the sam directory of the jsp


public class SimpleMenuApplet extends Applet {

public void init()
{
getParameter("fsize");
getParameter("data");
getParameter("image");

this.showStatus(getParameter("font"));
System.out.println(getParameter("fsize"));
System.out.println(getParameter("image"));
System.out.println(getParameter("data"));
System.out.println(getParameter("map")); // result is {alan=1}


}

public void start() {}

public void stop() {}

public void destroy() {}

}


// index.jsp below

<%@ page import="java.util.HashMap" %>
<%@ include file="SimpleMenuTarget.jsp" %>

<% String menuData = "alan is here thanks";
HashMap map = new HashMap();
map.put("alan", new Integer(1));
%>

<jsp:plugin type="applet" code="SimpleMenuApplet" codebase="."
width="250"
height="50"
jreversion="1.3"
>
<jsp:params>
<jsp:param
name="font"
value="SansSerif"
/>
<jsp:param
name="fsize"
value="12"
/>
<jsp:param
name="image"
value="Menu.gif"
/>
<jsp:param
name="data"
value='<%= menuData %>'
/>
<jsp:param
name="map"
value='<%= map %>'
/>

</jsp:params>

<jsp:fallback>
<B>Unable to start plugin!</B>
</jsp:fallback>

</jsp:plugin>







Regards,
Alan Mehio

[ May 11, 2008: Message edited by: Alan Mehio ]
[ May 11, 2008: Message edited by: Alan Mehio ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic