p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Passing a value from a Session variable to an Applet


Message #1 by "Ahmed Barradah" <havana200@h...> on Tue, 31 Jul 2001 09:18:13
I got the problem solved by chaging the page to an ASP instead of HTML.

Thank you Mr. Pinto and to everyone who tried to help

> Do u use that code in a ASP page and are u using the IIS?, if so i don't
> understand what happens. The IIS should substitute the
> "<%=Session("Username")%>" with the value of the session variable. It got
> nothing to do with the applet because he just begins to run when all the
> page arrives the client browser, and at that time the code should be 
already in HTML format.
> Sorry if i don't help u but don't find any more to sugest.
> 
> Best regards, Nuno Pinto
> -----------------------------------------------------
> Nuno Pinto              |            www.techlado.com
> Sócio Gerente           |               Apartado 3052
> Analista Programador    | Zona Industrial de Tabueira
> npinto@t...     |           3800 Aveiro Codex
> +xxx xxx xxx xxx        |            +xxx xxx xxx xxx
> -----------------------------------------------------
> 
> -----Original Message-----
> From: Ahmed Barradah [mailto:havana200@h...]
> Sent: terça-feira, 31 de Julho de 2001 9:18
> To: Code Clinic
> Subject: [proasp_codeclinic] Passing a value from a Session variable to
> an Applet
> 
> 
> 
> 
>  Hi everyone,
>     I would like to know how I can pass a Session variable called Session
> ("Username") to an applet. I have posted this question before and someone
> suggested to use the following:
> 
>  <APPLET CODE="HelloWWW.class" WIDTH=600 HEIGHT=50>
>       <PARAM NAME="Username" VALUE="<%=Session("Username")%>">
> 
>   <B>Error! You must use a Java enabled browser.</B>
> </APPLET>
> 
> However, when I load my web page the applet doesn't show the value of the
> Session("Username") instead it shows "<%=Session("Username")%
> 
> The code for my HelloWWW.java is
> 
> import java.applet.Applet;
> import java.awt.*;
> 
> // This appears in Core Web Programming from
> // Prentice Hall Publishers, and may be freely used
> // or adapted. 1997 Marty Hall, hall@a...
> 
> public class HelloWWW extends Applet {
>   private int fontSize = 40;
> 
>   public void init() {
>     setBackground(Color.black);
>     setForeground(Color.white);
>     setFont(new Font("Helvetica", Font.BOLD, fontSize));
>   }
> 
>   public void paint(Graphics g) {
>     String user_name = getParameter("Username");
>     g.drawString(user_name, 4, fontSize+5);
>   }
> }
> 
>  Does anyone know what's wrong with my code??? I truly would appreciate
> any help or suggestions.
> 
>  Thanks
>  Ahmed

  Return to Index