This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

post parameter to jsp from an applet

 
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???
 
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 ]
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic