Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

post parameter to jsp from an applet

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic