Two Beans of same Class - using in JSP with same name

Hi, all:
I want to do something like this:
<jsp:useBean id="entryBean" scope="session" class="myPackage.myClass"/>
<% if (entryBean.getUserRole().equals("Administrator)) { %>
<jsp:useBean id="adminBean" scope="session" class="myPackage.UserBean"/>
<% } else { %>
<jsp:useBean id="userBean" scope="session" class="myPackage.UserBean"/>
<% } %>
This, of course, works. But the problem comes when calling the methods. Usually I would use
<%= userBean.getName() %> - but in this case I don't know whether the bean I have is userBean or adminBean, and there doesn't seem to be a way to call them something other than their id in the session, so that I could get a variable name assigned to both, so I can just refer to a single object.
Any ideas?
Thanks, I appreciate any input.

You'd probably have to have another "fake" bean that references the bean you're using:
<jsp:useBean id="entryBean" scope="session" class="myPackage.myClass"/>
<%
  UserBean proxyBean;
  if (entryBean.getUserRole().equals("Administrator"))
%>
    <jsp:useBean id="adminBean" scope="session" class="myPackage.UserBean"/>
<%
    proxyBean = adminBean;
  else
%>
    <jsp:useBean id="userBean" scope="session" class="myPackage.UserBean"/>
<%
    proxyBean = userBean;
%>
Name: <%= proxyBean.getName() %><br/>No doubt someone's gonna grumble about it not really being a proxy but I couldn't think of another name for it.
Anyway, hopefully the idea here is clear.
Hope this helps.

Similar Messages

  • Combine two reports in query designer using key figure with sap exit

    Hi experts,
    i want to combine two reports in query designer using key figure with sap exit
    in the report 1 key figure calculation based on the open on key date(0P_DATE_OPEN)
    to calculate due and not due in two columns
    in report 2 key figure calculate in the time zones using given in variable Grid Width (0DPM_BV0) like due in 1 to 30 days, 31 to 60 days...the due amount based on the open on key date(0P_DATE_OPEN)
    to calculate in 1-30, 31-60, 61-90, 91-120, 121-150 and >150 days in 6 columns
    now i have requirement like this
    not due, 1-30, 31-60, >60, due,1-30, 31-60, >60 in 8 columns
    or
    not due, due, 1-30, 31-60, 61-90, 91-120, 121-150 and >150 in 8 col
    thank you

    Hi Dirk,
    you perhaps know my requirement,
    for the management to make used in one report,
    we have in reporting finacials Ehp3.
    Vendor Due Date Analysis - which show due, not due
    Vendor Overdue Analysis - show only due and analysis in time grid frame
    i want to combine in one report that show NOT DUE, DUE, DUE time frames in grid.
    krish...

  • How do Illstrator recognize if same plug-in will place with different name.

    Hi All,
    We are developing an Illutrator CS4 plug-in. we have source code of the plug-in. we need to add some extra features to that plug-in and build with new name. older one will work as it was. and newer one will work with new features. So both plug will resides same place with different name. the problem is, when I compile older soruce code and change the plug-in name. I'm getting error while loading plug-in it looks "older and newer version get conflict while name is different.
    Is Illustrator maintain any unique ID for each plug-in. if so, then where should i look for in my code?
    How do Illstrator recognize if same plug-in will place with different name?
    Any help would be appriciated.
    Thanks in advance,
    Johirul

    I don't believe Illustrator has anything like a UID for plugins. If you want them to co-exist, either make them named differently or put them in different sub-folders.
    On a related note, you CAN optionally set a plugin's name. You could then iterate over the plugin list at start up (before you set your name) and see if there's already a plugin with the same name. We do this to *prevent* our plugin from loading twice, but you don't seem to want that. I only mention this because this is about as close to 'unique identifiers' that AI gets, and frankly nothing stops you from having multiple plugins with the same name.

  • Reading two beans into one class?

    Hi,
    I am trying to deserialize a bean from a database (Oracle blob). I need help in introducing some flexibility, meaning that I can store objects of the same class but different versions, and I can cast them into just one class when I read them back.
    For example, initially I wrote an Employee object into the DB, and I had a local Employee class.
    class Employee {
         String name;
         int age;
         String getName() {...}
         void setName(String s) {...}
         int getAge() {...}
         void setAge(int i) {...}
    }Later, you might want to add a new field 'payRise' to the class, and use the new corresponding getPayRise() and setPayRise().
    In the DB, you still want to have both objects from both versions of the same class. Is there a way to still read the old object using the new Employee class? (so now we can read both versions) Currently I'm still having the InvalidClassException (serialVersionUID difference) even after manually setting the serialVersionUID . Please help.
    More code example:
       resultSet = statement.executeQuery("SELECT * FROM DB WHERE VERSION = 1")
       resultSet.next();  
       Employee e = (Employee) read (resultSet, "EMPLOYEE_OBJECT")
       // and also..
       resultSet = statement.executeQuery("SELECT * FROM DB WHERE VERSION = 2")
       resultSet.next();
       e = (Employee) read (resultSet, "EMPLOYEE_OBJECT")read() is the usual deserialization:
        public static Object read(ResultSet resultTransactionSet, String column)
                throws SQLException, IOException, ClassNotFoundException {
            byte[] buf = resultTransactionSet.getBytes(column);
            if (buf != null) {
                ObjectInputStream objectIn = new ObjectInputStream(
                        new ByteArrayInputStream(buf));
                return objectIn.readObject();
            return null;
        }Is there a way to do this?
    Thanks,
    Nico

    Serialization does not work for different versions of classes.
    You must use XMLEncoder to write the object to DB, and then later can retrieve with XMLDecoder.
    It will create an XML representation of your class depending only on your public apis, and works for different versions of the classes/objects.

  • How to track the same session using both jsp and servlets

    Hello, guys:
    "how to use jsp and servlet to track the same session",
    it seems to me my logoff.jsp never realize the session I established in my servlets.
    Here is how I set my session in my servlets:
    "     HttpSession session = req.getSession(true);
    session.setAttribute("userid",suserid);"
    Here is how I invalidate my session in my logoff.jsp
    " <%@ page language= "java" %>
    <%@ page import="javax.servlet.http.HttpSession" %>
    <%@ page session="false"%>
    Our Session id is : <%= session.getId() %>
    <% session.removeAttribute("userid");
    session.invalidate();
    %>
    Our Session id is : <%= session.getId() %>"
    but when I try to logoff using the logoff.jsp
    I always get following error message.
    "/home/jiao/jsp_webserver/tomcat/work/Standalone/localhost/syllabus/htmls/logoff_jsp.java:50: cannot resolve symbol
    symbol : variable session
    location: class org.apache.jsp.logoff_jsp
    out.print( session.getId() );"
    T.I.A.
    [Edited by: jiveadmin on Jun 18, 2003 10:32 AM]
    [Edited by: jiveadmin on Jun 18, 2003 10:33 AM]

    So,
    <%@ page session="false"%>
    That means the jsp never instantiates the build in session object.
    <%@ page session="true"%>
    means jsp will instantiates a session object if there are no existing ones
    how about I just delete the line,
    does that mean the jsp will find the existing session object for me?
    So I can do something like
    Our Session id is : <%= session.getId() %>
    <% session.removeAttribute("userid");
    session.invalidate();
    %>
    directly.
    T.I.A.

  • Problems Creating a Java Class using a webservice with certificate

    hi,
    i'm developing a java class that call's a webservice that needs a certificate, i'm not used to work with java, last time was 10 years ago, so i'm having some troubles because of the certificate.
    I already add the certificate using java control panel > Security > Certificates. When testing i get the following error: IOException (java.io.IOException: subject key, Unknown key spec)
    I think I need to define the certificate in my class, but i'm having a lots of trouble with the samples that i found over the internet, nothing works and i'm running out of time.
    This is my Class
    create or replace and compile java source named "FishInfoAt" as
    import java.net.*;
    import java.io.*;
    import java.security.*;
    public class FishInfoAt
         public FishInfoAt()
         public static String send(String urlfishinfoat, String mensagem, String mensagem1, String mensagem2, String mensagem3)
              // Init
              String response = "";
              String msgtotal = mensagem+mensagem1+mensagem2+mensagem3;
              String a = "";
              HttpURLConnection conn = null;
              try{
                   URL url = new URL(urlfishinfoat);
                   conn = (HttpURLConnection) url.openConnection();
                   conn.setRequestMethod("POST");
                   conn.setRequestProperty("Content-type", "text/xml; charset=utf-8");
                   conn.setRequestProperty("SOAPAction", "https://servicos.portaldasfinancas.gov.pt:401/sgdtws/documentosTransporte/");
                   conn.setRequestProperty("Content-Length","" + msgtotal.length());
                   conn.setDoOutput(true);
                   conn.setDoInput(true);
                   conn.connect();
                   OutputStream out = conn.getOutputStream();
                   out.write(msgtotal.getBytes());
                   out.flush();
                   InputStream in = conn.getInputStream();
                   int value;
                   while( (value = in.read()) != -1)
                        response+=(char)value;
              catch(Exception e)
    response = ("*** ERROR - IOException (" + e.getMessage() + a + ")");
    return response;
    /

    Hi Deepak,
    Could you please let us know upto which line your code is going safe. Try printing the value in the structure before you send that to the method GetUGEntity().
    I am not too sure that would be a problem. But I have faced a problem like this, wherein I tried to access a structure for which I have not allocated memory and hence got exception because of that.
    Since your JNI code seems to be error free, I got doubt on your C part. Sorry.
    Dhamo.

  • Using multiple SSIDs with same name but different PSKs

    I have a central WLC 2504 controller that is being used for remote site FlexConnect 1141 APs. They all advertise three different SSIDs. One SSID is a global SSID that is the same at every office. One is a hidden SSID using 802.1x machine auth.
    The one I am trying to get working is the local office guest network. These SSIDs are all the same at each office but should have different PSKs. They are local to the office, therefore would only ever be applied to a specific FlexConnect group.
    I understand why in theory this is generally not a good idea but given these are for remote sites I'd like it to be possible. I always get this message though:
    "WLAN with duplicate SSID and L2 security policy found"
    Is there a way around this? New WLC code that allows it maybe?

    I was able to configure three (more I think possible) WLANs with same SSID name and all are WPA2-AES-PSK on the same WLC and all are enabled at hte same time.
    Note that you can not have any of those broadcasting on same AP group. Each WLAN can be only broadcasted on a separate AP group. For your sites, It will probably need you to define an AP group for each site to broadcast different WLANs on different sites.
    You can do that if all your WLANs have an ID of 17 or higher. (the reason is, WLANs of 1-16 are by default broadcasted on the default AP group. and because those can not be on the same AP group - including the default one - then you can't have them with WLAN IDs 1-16. i.e on same - default - AP group)
    HTH
    Amjad
    rating useful replies is more useful than saying "Thank you"

  • RV042 when using both WAN with same DNS servers doesn't work properly

    Hi there, I have a RV042 and upgraded it to the latest firmware available. The problem is the following:
    when I have on WAN1:
    PROVIDER A - MUNDIVOX
    IP: 200.201.190.202
    SM: 255.255.255.248
    GW: 200.201.190.201
    DNS1: 200.196.48.20
    DNS1: 200.196.48.21
    and on WAN2:
    PROVIDER B - TRINN
    IP: 189.113.129.230
    SM: 255.255.255.252
    GW: 189.113.129.229
    DNS1: 189.113.128.3
    DNS2: 189.113.128.2
    The load balance works fine and network redirection works fine I can route all trafic from ips 192.168.0.1 to 192.168.0.50 and specific protocols such as UDP on port 5060 for my SIP Phone for ips 192.168.0.101 to 192.168.0.120 works fine.
    The problem is when I change WAN1 to:
    PROVIDER A - TRINN
    IP: 189.113.132.2
    SM: 255.255.255.248
    GW: 189.113.132.1
    DNS1: 189.113.128.3
    DNS2: 189.113.128.2
    And Wan 2 I keep the same provider that would be the same as Provider for WAN1 now:
    PROVIDER B - TRINN
    IP: 189.113.129.230
    SM: 255.255.255.252
    GW: 189.113.129.229
    DNS1: 189.113.128.3
    DNS2: 189.113.128.2
    The load balace simply doesnt work, all the IPs in the range of 192.168.0.1 to 192.168.0.50 that should be using WAN1, uses WAN2, in fact, as far as I could see all my trafic goes with that configuration to WAN2 only, but if I remove the cable from WAN2, all trafic goes to WAN1, so, very strange... if I put back on WAN1 the MUNDIVOX provider from situation 1, everything gets back to the way it should be.
    If someone can help I would appreciate,
    Regards,
    Cristiano

    Dear Cristiano,
    Thank you for reaching the Small Business Support Community.
    It's been several days since you posted your inquiry with still no answer from any of the community members, very interesting situation you have here and unfortunately my only suggestion is to contact the Small Business Support Center to have a TAC engineer check this out;
    https://www.cisco.com/en/US/support/tsd_cisco_small_business_support_center_contacts.html
    I wish I could be a better help and please do not hesitate to reach me back if there is anything I may assist you with in the meantime.
    Kind regards,
    Jeffrey Rodriguez S. .:|:.:|:.
    Cisco Customer Support Engineer
    *Please rate the Post so other will know when an answer has been found.

  • HT201412 my ipad3 does not turn on after it went off while using it, anyone with same experience and have it resolve already?

    my Ipad 3 will not turn-on after it went off while using it, anyone with the same experience and have it resolve?

    Is the battery charged?
    Frozen or unresponsive iPad
    Resolve these most common issues:
        •    Display remains black or blank
        •    Touch screen not responding
        •    Application unexpectedly closes or freezes
    http://www.apple.com/support/ipad/assistant/ipad/
    iPad Frozen? How to Force Quit an App, Reset or Restart Your iPad
    http://ipadacademy.com/2010/11/ipad-frozen-how-to-force-quit-an-app-reset-or-res tart-your-ipad
    What to Do When Your iPad Won't Turn On
    http://ipad.about.com/od/iPad_Troubleshooting/ss/What-To-Do-When-Your-Ipad-Wo-No t-Turn-On.htm
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    iPad: Basic troubleshooting
    http://support.apple.com/kb/TS3274
     Cheers, Tom

  • Using File Adapter with Logical Name

    I am creating a file adapter with Logical name. Apart from giving the Logical name is there any other configuration that I am suppose to do on the Web Logic before I start using it?
    Thanks in Advance.

    After configuring the file adapter, all you need to do is , give the path as a value for the logical name which you have created earlier. That you can do on the file adapter property inspector. There is no need to do anything on the server level. Lemme know
    Thanks,
    N

  • Can I use web.show_document with forms name parameter ?

    Hi All,
    I need to pass URL to web.show_document but with form name too. Is it possible?
    I'd like to do something like web.show_document('url?report=myReport','_blank')
    Thanks in advance
    Edited by: _blackjack on Dec 13, 2012 2:17 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Yes, you can use any valid URL within web.show_document

  • How to use Classes stored in "Classes" folder in JSP with tomcat ?

    Hello friends
    im using tomcat as server and MySQL as a Backend. now i am using the date calculation in Diff.class files which i have stored in catalina_home/webapps/prj_dev/Prj_files/classes/diff/DIff.class.
    now i am getting error that :
    Generated servlet error:
    Only a type can be imported. diff.Diff resolves to a package
    wht i have to do ?

    I don't include the "classes" word in my import anymore.. Waa.. I'm going nuts.. T.T
    Now, I'm trying to use the class through useBean..
    this is how my application looks like:
    /webapps
    -----/hangman-jsp
    ------------index.jsp
    ------------/WEB-INF
    -------------------web.xml
    -------------------MysteryPhrase.java
    -------------------/classes
    ---------------------------/beans
    ----------------------------------MysteryPhrase.class
    -----------/images
    -------------------hangman.gif
    This is what is in my MysteryPhrase:
    package beans;
    import java.lang.String;
    import java.lang.StringBuffer;
    public class MysteryPhrase {
         private String answer;
         private StringBuffer mysteryPhrase;
         private int guesses;
         private char[] alphabet;
         public MysteryPhrase () {
         this.alphabet = new char[26];
    public void setMysteryPhrase (String mysteryPhrase) {
         this.answer = mysteryPhrase;
         this.mysteryPhrase = new StringBuffer(mysteryPhrase.length());
         for (int i = 0; i < mysteryPhrase.length(); i++) {
              this.mysteryPhrase.setCharAt(i, '_');
    public void setGuess (char guess) {
         for (int i = 0; i < answer.length(); i++) {
              if (answer.charAt(i) == guess) {
                   mysteryPhrase.setCharAt(i, guess);
         guesses++;
    public String getMysteryPhrase () {
         return mysteryPhrase.toString();
    public String getAnswer () {
         return answer;
    public int getGuesses () {
         return guesses;
    This is what is in my index.jsp (It is not yet finished..I just started..)
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <jsp:useBean id="phrase" class="beans.MysteryPhrase"/>
    <jsp:setProperty name="phrase" property="MysteryPhrase" value="Hello!"/>
    <html>
         <head>
              <title>JSP/JSTL Implementation of Hangman</title>
              <style type="text/css">
                   div {
                        color: white;
                        background-color: gray;
                        position: absolute;
                        border-style: solid;
                        border-width: thin;
                        width: 20%;
                        height: 30%;
                        text-align: center;
                   #guessBoard {
                        top: 28%;
                        left: 42%
                   #mysteryPhraseBoard {
                        top: 50%;
                        left: 25%;
                        z-index: 2;
                   #statisticsBoard {
                        top: 57%;
                        left: 58%;
                        z-index: 2;
                   #categoryBoard {
                        top: 23%;
                        left: 10%
                   #hangman {
                        top: 7%;
                        left: 70%;
                   #char {
                        width: 20px;
                   body {
                        background-color: black;
              </style>
         </head>
         <body>
              <div id="categoryBoard">
                   <form method="post">
                        Please choose a category:
                        <select name="category">
                             <option>Category 1</option>
                             <option>Category 2</option>
                             <option>Category 3</option>
                             <option>Category 4</option>
                             <option>Category 5</option>
                             <option>Category 6</option>
                             <option>Category 7</option>
                             <option>Category 8</option>
                        </select>
                        <input type="submit" value="Change"/>
                   </form>
              </div>
              <div id="mysteryPhraseBoard">
                   The mystery phrase is
              </div>
              <div id="guessBoard">
                   <form method="post">
                        Enter a letter: <input id="char" type="text" name="letter"/>
                        or
                        Enter a word: <input type="text" name="word"/>
                        <input type="submit" value="Guess"/>
                   </form>
              </div>
              <div id="statisticsBoard">
                   Guesses: 0
                   Remaining Letters: 8
              </div>
              <div id="hangman">
                   <img src="images/hangman.gif"/>
              </div>
         </body>
    </html>

  • Error when I import classes using directive JSP page

    Hi all!
    I have installed JDeveloper 11g (11.1.1.3.0)
    My applications are located in the C:\dir (JDEV_USER_DIR = C:\dir)
    I Created application "Appliation1". In it i created 2 projects (Project1, in it beans session entity and other java classes; Project2, in it JSP).
    I want import classes from Project1 to Project2 using next directive:
    <%@ page contentType="text/html;charset=windows-1252"
    import="project1.*"%>
    so in Project properties of Project2 set the way to classes in Project1.
    When i run JSP an error occurred:
    Error(4,9): The import project1 cannot be resolved
    Maybe i'm not set correctly the way to the classes
    Thanks in advance.

    angelr, thanks, it helped me)
    In jdeveloper 10g i set address in Project Properties->Libraries and Classpath->Add JAR/Directory;
    and set the way to my classes;
    and it worked.
    in the 11 version seems different

  • How to apply warp stabilization to the same clip used twice in the same timeline

    If I use the same source clip in a timeline (say 3 or 4 different sections of the clip by dropping the same clip on the timeline and just trimming it differently) and want to stabilize them all, how do I do that?  The first instance of the clip lets me use warp stabilization, but then when I try to apply it to later instances of the same clip in the timeline, it says I can't do that.   How do I apply the stabilization to later instances of the same clip in the timeline?
    Thanks

    After trimming the clip just apply the warp stabiliser to it without copying and pasting. You can't copy and paste the warp stabiliser because it needs to analyse the pixels of each clip everytime its applied.

  • Using recompressed files with same name -- DVD Studio keeps crashing!

    Hi,
    I completed a project for a client, but they now want music added to certain parts of it. Because there are so many menus, buttons, etc., I decided to add the music in FCP, recompress the files using the same name as the original file used in DVD Studio, and hoped that everything would then relink.
    It does relink (it gives me the message that assets may have changed timing, etc) but any time I try to do something (like Simulate it), it crashes.
    What am I doing wrong? Is there a better or easier way to solve this problem? Would greatly appreciate anyone's help.
    Thanks!

    In theory it SHOULD work, FCP seems to do a good job updating say if you are using a Photoshop file and you change it. The timeline in FCP shows the change and I never seem to get any problems there. With DVDSP, however, it's a whole different story. As the previous poster said, change the name and that should work. It sounds like your project might be beyond fixing that way however.
    Here's a little more on the subject of replacing assetts and what I learned: http://discussions.apple.com/message.jspa?messageID=9788507#9788507

Maybe you are looking for