HttpSession.getAttribute

Hi, problem of HttpSession is encountered with App. Server 8.1 but works fine with App. Server 6.5
Can anyone suggest how to solve this problem on App. Server 8.1?
Many thanks!
HttpSession.getAttribute("LoginName") works fine with JDK1.3 App. Server 6.5. However, it returns null if working with JDK 1.5 with App. Server 8.1
From the logs below, you can see that getSession returns the session correctly in both App. Server 6.5 and App. Server 8.1
Server running on JDK 1.3 with Application Server 6.5::
2006-07-12 17:16:25,125 [INFO ] -com.MonScr.servlet.Init-In BaseServletBase initialize started...
2006-07-12 17:16:25,125 [INFO ] -com.MonScr.servlet.Init-In ServletBase initialize() started...
2006-07-12 17:16:25,140 [INFO ] -com.MonScr.servlet.Init-In ServletBase initialize() finished...
2006-07-12 17:16:25,140 [INFO ] -com.MonScr.servlet.Init-In BaseServletBase initialize finished...
2006-07-12 17:16:25,156 [INFO ] -com.MonScr.servlet.Init---get HttpSession oHttpSession = [email protected]2
2006-07-12 17:16:25,156 [INFO ] -com.MonScr.servlet.Init-In noSession - LoginName:[T242180]
Server running on JDK 1.5 with Application Server 8.1 2005 Q1:
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-In BaseServletBase initialize started...
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-In ServletBase initialize() started...
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-In ServletBase initialize() finished...
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-In BaseServletBase initialize finished...
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-****************************************************
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-HttpSession oHttpSession = org.apache.catalina.session.StandardSessionFacade@1c9058f
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-****************************************************
2006-07-12 15:05:26,703 [INFO ] -com.MonScr.servlet.Init-In noSession - LoginName:[]
Here is the code for your reference:
HttpSession oHttpSession = poHttpServletRequest.getSession(false);
LoggingMsg.log( "INFO","--get HttpSession oHttpSession = "+getLoginName(poHttpSession)", true);
if ( noSession(oHttpSession))
LoggingMsg.log( "INFO", "****************************************************", true);
LoggingMsg.log( "INFO", "HttpSession oHttpSession = " + poHttpServletRequest.getSession(false), true);
LoggingMsg.log( "INFO", "****************************************************", true);
LoggingMsg.log( "INFO", "No Session", true);
return;
protected boolean noSession(HttpSession poHttpSession)
     LoggingMsg.log( "INFO","In noSession - LoginName:["+getLoginName(poHttpSession)+"]", true);
return (poHttpSession == null || getLoginName(poHttpSession).equals(""));
public static String getLoginName(HttpSession poHttpSession)
if ( poHttpSession == null )
return "";
return CommonFunc.mapNull2Empty((String) poHttpSession.getAttribute("LoginName"));
}

That's quite inefficient. You can either ignore the warning (since you know the results is a list of strings), or you can use the @SuppressWarnings annotation on your assignment line if your version of javac supports it (some early 1.5 implementations didn't).

Similar Messages

  • How to get multiple values using HttpSession.getAttribute(java.lang.String)

    Hey Guys
    I'm trying to find a way to get multiple values using the following method
    HttpSession.getAttribute(java.lang.String)
    Here's the scenerio. Its a already written application and now i'm trying to make some changes. earlier in the jsp page a combo box was used and value was retrieved in the servlet using the getAttribute method of Session. Now I'm using a html multiple selection list and have to retrieve all the values selected in the list in the servlet. Can anyone please suggest me how to do that. HTTPRequest class has a method getParameterValues which will let me do that but i have to do is using HTTPSession.
    Thanks for your time to read this

    I'm not sure what you are trying to do. You can only use session.getAttribute to retrieve something that has already been stored in the session with a previous setAttribute. If you need to store multiple values under one attribute name using setAttribute, you can store an array, or an ArrayList or whatever type of Collection you want. The request.getParameterValues method is the only way you can retrieve form parameters than can have multiple values. If the servlet hasn't already processed these parameters and put them into the session for you, you have to use request.getParameterValues.

  • HttpSession getAttribute() generics

    Hi, I am trying to get a List<String> from an HttpSession
    List<String> titles = (ArrayList<String>) thisSession.getAttribute("titles");
    I am getting a compiler warning, unchecked cast.
    I found the following method that solves the warning:
    private static <T> void convert(Class<T> type, Collection raw, Collection<T> cooked) {
    for (Iterator i = raw.iterator(); i.hasNext();) {
    cooked.add(type.cast(i.next()));
    Does anyone have a better solution to avoid the warning?
    Thanks

    That's quite inefficient. You can either ignore the warning (since you know the results is a list of strings), or you can use the @SuppressWarnings annotation on your assignment line if your version of javac supports it (some early 1.5 implementations didn't).

  • How to get Multiple Values for a key from a session object?

    Hi,
    It might seem dumb but I am facing a problem here with the session object. I'll paste the session object's content from the netbeans "Local Variables" window for clarity -
    Name Type Value
    hsession StandardSessionFacade #66
    session LWSFSession #69
    inherited
    attributes Hashtable #80
    [0] Hashtable$Entry "cart"=>#115
    key String "cart"
    value DummyCart #115
    item null
    submit null
    v Vector
    [0] String Full Metal Jacket
    [1] String As Good As It Gets
    [2] String Tim
    What I want is to get the values "Full Metal Jacket", "As Good As It Gets" and "Tim" from the session obejct?
    The problem I am facing is that if I do a session.getAttribute("cart"), I'll get a single value in return. What will that value be? Will it be "item", "submit" or "v"? And if I want all the values in v above, how can I get them?
    Thanks.

    None of the above.
    HttpSession.getAttribute() will return what you put into it using HttpSession.setAttribute(). In your case, it'll return an Object which you need to cast to DummyCart. Then you can access the data in DummyCart using the API of the DummyCart class.
    hth

  • Distributed sessions for multiple web-apps in a single App. Server (v.8.1)

    I have 3 applications on App. Server 8.1 (running on JDK 1.5)
    App-A handles login
    App-B and App-C are functions that are accessible after login is validated.
    It works fine with App. Server 6.5 (JDK 1.3)
    But the distributed session cannot be shared in App. Server 8.1 (JDK 1.5)
    So App-A handles sign on and stores the user's Login Name on the session.
    App-B and App-C read the user's login name from the session object and grant access to different modules.
    1. Starting App-A and perform login
    2. Starting App-B from App-A (it is linked there)
    3. Starting App-C from App-A (it is linked there)
    In step 1, a new session is created for the user, an attribute ("LoginName") is put in the session - ie. using HttpSession.setAttribute()
    In step 2, the program checks for attribute "LoginName" from the session object - ie. using HttpSession.getAttribute()
    If not found, redirect to login; if found, then continue with App-B
    In step 3, same as in step 2 above.
    It works fine with App. Server 6.5 but problem occurs in step 2 and 3.
    web.xml of App-A, App-B and App-C:
    <i>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>App-A</display-name>
         <distributable/>
    </i>
    sun-web.xml of App-A, App-B and App-C
    <i>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
    <sun-web-app>
    <session-config>
    <session-manager persistence-type="memory">
    <manager-properties>
    <property name="persistenceFrequency" value="web-method"/>
    </manager-properties>
    <store-properties>
    <property name="persistenceScope" value="session"/>
    </store-properties>
    </session-manager>
    </session-config>
    </i>

    Distributed sessions has nothing to do with different web applications. The concept is about distributing load for the same application between several appserver instances running on the same box(different jvm) or on some other box in the network.
    What you used with iAS 6.5 is not available in 8.1 because sharing sessions between web apps is forbidden by the servlet spec. You should consider repackaging your apps. into a single web app. or using other way of signing/verifying user identity(check Sun Access Manager for example).
    Have a look at this thread as well: http://swforum.sun.com/jive/thread.jspa?threadID=100931

  • Tag Extra Info Classes not recongnized on 8.1

              I am trying to migrate a web application from 6.1 to 8.1 and am running into an
              issue
              with custom tag libraries. These tags have TEI classes associated with them that
              are
              used to define fields in the JSP page where the tags are used. These fields are
              then
              referenced in the JSP. The JSP compiles fine in 6.1 but in 8.1 the compiler
              reports that
              it is unable to recognize the symbol for the various fields defined in the TEI
              and the
              JSP therefore fails to compile.
              Has anyone else run into this problem? Any workarounds or ideas about what needs
              to be
              done to make it work?
              Thanks in advance for your help.
              Regards,
              David Roytenberg
              

    There's already a patch available i believe.. (i cant find the CR rightnow)
              but im sure WebLogic support will help you out.
              "David Roytenberg" <[email protected]> wrote in message
              news:[email protected]...
              >
              > I requested the patch. To your knowledge does it exist or
              > is BEA still working on it?
              >
              > Regards,
              >
              > David
              >
              > "Nagesh Susarla" <[email protected]> wrote:
              > >Ahhh.... This is a bug in 8.1. Unfortunately AT_END attributes are not
              > >being declared in the generated java file. Please contact
              [email protected]
              > >and ask for a patch for this issue.
              > >--
              > >Nagesh
              > >
              > >"David Roytenberg" <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> HI Nagesh,
              > >>
              > >> Thanks for your reply. Here is the info you requested:
              > >>
              > >> The TEI class looks like this:
              > >>
              > >> import javax.servlet.jsp.tagext.*;
              > >>
              > >> public class LoginTEI extends TagExtraInfo
              > >> {
              > >>
              > >> public LoginTEI()
              > >> {
              > >> }
              > >>
              > >> public VariableInfo[] getVariableInfo(TagData tagdata)
              > >> {
              > >> VariableInfo variableinfo = new
              > >VariableInfo(tagdata.getAttributeString
              > >>
              > >> ("id"), "com.actuate.reportcast.tags.common.LoginTag",
              > >true,
              > >VariableInfo.AT_BEGIN);
              > >> VariableInfo variableinfo1 = new VariableInfo
              > >> ("userMap", "com.actuate.reportcast.utils.UserMap",
              > >true, VariableInfo.AT_END);
              > >> VariableInfo variableinfo2 = new VariableInfo
              > >> ("errorLogin",
              > >"com.actuate.reportcast.dstruct.ErrorObject",
              > >> true,
              > >> VariableInfo.AT_END);
              > >> VariableInfo avariableinfo[] = {
              > >> variableinfo, variableinfo1, variableinfo2
              > >> };
              > >> return avariableinfo;
              > >> }
              > >> }
              > >>
              > >> Here is an excerpt from the JSP that won't compile. Note that
              > >> the reference to errorLogin generates an error from the JSP Compiler.
              > >>
              > >> ...
              > >> // Retrieve any available parameters from the url.
              > >> String sAuthID = null;
              > >> String sDesignation = null;
              > >> String sLoginID = paramBean.getParameter("userID");
              > >> String sPassword = paramBean.getParameter("password");
              > >>
              > >> // --Start Portlet support
              > >> String sPrefix = paramBean.getParameter("pfx");
              > >> if ( sPrefix != null )
              > >> {
              > >> HttpSession httpsession = request.getSession();
              > >> sLoginID =
              (String)(httpsession.getAttribute(sPrefix+"userID"));
              > >> sPassword =
              > >(String)(httpsession.getAttribute(sPrefix+"password"));
              > >> }
              > >> // --End Portlet support
              > >>
              > >> String sVolume = paramBean.getParameter("volume");
              > >> String sServer = paramBean.getParameter("server");
              > >> String sServerURL = paramBean.getParameter("serverURL");
              > >> String sSystemName = paramBean.getParameter("systemName");
              > >> String sDaemonURL = paramBean.getParameter("daemonURL");
              > >> boolean bForceLogin = (new
              > >Boolean(paramBean.getNonNullParameter("forceLogin"))).booleanValue();
              > >> String sUserHomeFolder = null;
              > >> UserMap userMapObj = null;
              > >> // HANDLE LOCALES IN THIS BLOCK HERE
              > >> LocaleManager lm = LocaleManager.instance();
              > >> TimeZoneManager tzm = TimeZoneManager.instance();
              > >>
              > >> if (sLoginID != null)
              > >> {
              > >> bForceLogin = true;
              > >> }
              > >>
              > >> %>
              > >> <login:login id="login" userID="<%= sLoginID %>" password="<%=
              > >sPassword %>"
              > >> server="<%= sServer %>" force="<%= bForceLogin %>"/>
              > >>
              > >> <%
              > >>
              > >> if (errorLogin != null)
              > >> {
              > >> //redirect the browser back to the login page
              > >> String sErrorCode = errorLogin.getErrorCode();
              > >> response.sendRedirect(StaticFuncs.resolveURL(request,
              > >"/login.jsp") +
              > >> paramBean.createQueryString() + "&errorMessage=" +
              > >StaticFuncs.encode(errorLogin.getMessage())
              > >> + "&errorcode=" + sErrorCode);
              > >> return;
              > >> }
              > >> ....
              > >>
              > >>
              > >> The compiler's response to the snippet of code above is
              > >>
              > >>
              > >> [java]
              >
              >/export/home/roytenbd01/build/CR/actuate/acweb/war/WEB-INF/classes/jsp_serv
              l
              > >et/__authenticate.java:272:
              > >> cannot resolve symbol
              > >> [java] symbol : variable errorLogin
              > >> [java] location: class jsp_servlet.__authenticate
              > >> [java] if (errorLogin != null) //[ /authenticate.jsp; Line:
              > >99]
              > >> [java] ^
              > >> [java]
              >
              >/export/home/roytenbd01/build/CR/actuate/acweb/war/WEB-INF/classes/jsp_serv
              l
              > >et/__authenticate.java:275:
              > >> cannot resolve symbol
              > >> [java] symbol : variable errorLogin
              > >> [java] location: class jsp_servlet.__authenticate
              > >> [java] String sErrorCode = errorLogin.getErrorCode();
              > >//[
              > >/authenticate.jsp;
              > >> Line: 102]
              > >> [java] ^
              > >> [java]
              >
              >/export/home/roytenbd01/build/CR/actuate/acweb/war/WEB-INF/classes/jsp_serv
              l
              > >et/__authenticate.java:276:
              > >> cannot resolve symbol
              > >> [java] symbol : variable errorLogin
              > >> [java] location: class jsp_servlet.__authenticate
              > >> [java]
              response.sendRedirect(StaticFuncs.resolveURL(request,
              > >"/login.jsp")
              > >> + paramBean.createQueryString() + "&errorMessage=" +
              > >StaticFuncs.encode(errorLogin.getMessage())
              > >> + "&errorcode=" + sErrorCode); //[ /authenticate.jsp; Line: 103]
              > >> [java]
              > >>
              > >>
              > >> Any ideas?????????????
              > >>
              > >> Regards,
              > >>
              > >> David Roytenberg
              > >>
              > >>
              > >> Nagesh Susarla <[email protected]> wrote:
              > >> >David Roytenberg wrote:
              > >> >
              > >> >> I am trying to migrate a web application from 6.1 to 8.1 and am
              > >running
              > >> >into an
              > >> >> issue
              > >> >> with custom tag libraries. These tags have TEI classes associated
              > >> >with them that
              > >> >> are
              > >> >> used to define fields in the JSP page where the tags are used.
              > >These
              > >> >fields are
              > >> >> then
              > >> >> referenced in the JSP. The JSP compiles fine in 6.1 but in 8.1
              > >the
              > >> >compiler
              > >> >> reports that
              > >> >> it is unable to recognize the symbol for the various fields defined
              > >> >in the TEI
              > >> >> and the
              > >> >> JSP therefore fails to compile.
              > >> >>
              > >> >> Has anyone else run into this problem? Any workarounds or ideas
              > >about
              > >> >what needs
              > >> >> to be
              > >> >> done to make it work?
              > >> >>
              > >> >> Thanks in advance for your help.
              > >> >>
              > >> >> Regards,
              > >> >>
              > >> >> David Roytenberg
              > >> >
              > >> >Can you post the fields/symbols in question.
              > >> >
              > >>
              > >
              > >
              >
              

  • Accessing String assigned in a JSP from a Servlet?

    Hello all, I was wondering if there is a way to access a String object that was assigned by an HttpSession object in a JSP from a Servlet. What happens is, in my application a user logs in, an HttpSession object is instantiated and all of the user credentials are assigned within a JSP like:
    HttpSession httpSession = request.getSession( false );
    String userName = httpSession.getAttribute("userName);
    ...{code}
    Next, I have a Servlet (which is really just a Proxy to a different server), that I need to log some information with, namely the userName String. Is there a way I can access that String without instantiating another HttpSession object? Because when the timeout occurs (or when the user clears his cache I have found), the HttpSession becomes invalidated (even if I use  +HttpSession#getSession( true )+) and the +HttpSession#getAttribute+ call fails (userName is just null). So is this possible to do?
    Thanks in advance!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    dnbphysicist wrote:
    I understand you cannot recover attributes from a dead session, this is why I wanted to be able to access a variable that is pulled from the Session immediately after login so I can still get to it even once the session is dead.
    Normally a session doesn't go dead after login.
    I imagine that by using application scope the app would confuse the userName with other users that are logged in?Certainly. It was just an example. But your data clearly belongs in the session, so just keep it in the session. If the session get invalidated while it should not get invalidated, then your problem truly lies somewhere else.
    I am definitely not arguing you latter point either :) A lot of this code I inherited unfortunately from previous developers and we are in desperate need of a redesign.I wish you much luck with that.

  • Jsp Page session vaiable to java class and vise versa

    Hi to all,
    I am new to jsp, i have to programs, one jsp page and another java class. in jsp page i get the user data from html form and put the id in session. here i have to call the session vaiable to my java class where it (variable)initialize a file name.
    and same i have to call the java class to jsp page which insert statements to sql server,
    Please Help Me.

    //My Java Class file
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import javax.servlet.http.HttpSession;
    import java.sql.Statement;
    public class StuInfo extends Object {
    //main method begins execution of Java application
    public static void main (String args[]){
    String StuFile = "C://"+iD+".txt"; // Here i have to get the session varaible.(ID)
    try {
    In my jsp Page i initilized session as
    session.setAttribute("ID",StuId);
    I am not able to understand where i have to declear the HTTPSession#getAttribute("ID");

  • Get session in JSP

    I have got a problem, would like to seek help. thanks in advance:P
    HttpSession httpsession=request.getSession(true);
    httpsession.setAttribute("user", getUser(userid));//getUser(userid) will return a user
    User user=(User)httpsession.getAttribute("user");
    i have set a session for a user in a class and i can get the user in the same class, but how can i get the user in JSP??
    i have tried as follows:
    <% HttpSession httpsession=request.getSession(true);
    User user=(User)httpsession.getAttribute("user");
    if (user.getRole().equals("user")){ %>
    but when i compile the JSP, it said "User not found"
    what wrong with the code??
    it seems that can't call a bean

    Hi,
    You are using a custom 'User' class, so need to import it. Add this line at the top of the JSP page:
    <%@ page import="pack.name.User" %>
    // put the fully qualified User class name hereif you already have the <%@ page %> directive, just add the import attribute to it.
    -Srinath

  • Problems with Portlet projects

    Hi,
    Started using Java Studio Enterprise recently (now that it's free) since I am developing portlet applications for an organization running the enterprise system in production use.
    The IDE is great (love the UML stuff) but I've run in to a couple of problems that are really slowing me down.
    When I run a portlet project in the Application Server (using the Harness portlet provider/Portal Server simulator) I noticed that every request made to the Portlet is duplicated. So if I have a line like...
    System.out.println("Portlet: doView()");
    ... in the Portlets doView method I get this in the server log:
    [#|2006-01-13T12:09:27.093+0200|INFO|sun-appserver-pe8.1_02|javax.enterprise.system.stream.out|_ThreadID=31;|
    Portlet: doView()|#]
    [#|2006-01-13T12:09:27.109+0200|INFO|sun-appserver-pe8.1_02|javax.enterprise.system.stream.out|_ThreadID=31;|
    Portlet: doView()|#]
    Why is this happening and what can I do about it? I first noticed this when I was using a DAO from a portlet and all my sql statements got executed twice!
    The other thing that's annoying me is that when i shutdown the ide, my datasource reference is whiped out from my web.xml file. So everytime I start Studio Enterprise I have to manually edit the web.xml file to get my datasource working. I have configured my datasource with the IDE (new File > Sun Resource -> JDBC resource...).
    Any ideas?

    Unfortunately this is a bug in in JSE 8.0. It will be fixed in the currently developed JSE 8.1, but for now there exists a work-around (quoting our portlet builder engineer):
    1. Go to folder <userdir>/config/ps/Harness
    (e.g.: "C:\Documents and Settings\<username>\.jstudio\Ent8\config\ps\Harness")
    2. Open jsp file "PSSimTarget.jsp" in
    <userdir>/config/ps/Harness/web/desktop/default/harness/PSSimTarget.jsp
    3. Find next lines at the top of the file:
    <i18n:set
    var="locale"><%=ProviderHarness.getHarness(request,response,pageContext).getLocaleString()%></i18n:set>
    <i18n:setLocale value="${locale}" scope="session"/>
    <i18n:setBundle basename="i18n.Bundle" var="myBundle"/>
    4. Replace it with next lines:
    <%
    HttpSession httpsession = request.getSession();
    ProviderHarness tmpObj =
    (ProviderHarness)httpsession.getAttribute("desktop.Simulator.ProviderHarness");
    if (tmpObj == null) {
    %>
    <i18n:set var="locale"><%=ProviderHarness.getHarness(request,response,pageContext).getLocaleString()%></i18n:set>
    <%
    %>
    <i18n:setLocale value="${locale}" scope="session"/>
    <i18n:setBundle basename="i18n.Bundle" var="myBundle"/>
    Every time when you start studio with new userdir, you should change PSSimTarget.jsp to avoid double requests.

  • Jpanel to a picture in Servlet without saving to disk

    Hi. I need to display a graph on the fly in a servlet. I currently have the graph in a JPanel. I saw all the posts about how to save this to disk. Can anyone please suggest a way to display it (servlet generated HTML) without saving it to disk?
    Any suggestions for a good tutorial on servlets serving generated images would also be highly appreciated.
    Thank you very much,
    Arijit

    Hi,
    I have an example that works with Java Server Faces based web components and produces svg dynamically. The same strategy can be used for jpg or any other graphical format.
    * SessionServlet.java
    * Created on June 3, 2004, 12:09 AM
    package com.hypernex.xml.svg;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * @author  hyperdev
    * @version
    public class SessionServlet extends HttpServlet
        /** Initializes the servlet.
        public void init(ServletConfig config) throws ServletException
            super.init(config);
        /** Destroys the servlet.
        public void destroy()
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
            ServletContext context=getServletContext();
            java.util.Enumeration e=context.getServlets();
            while(e.hasMoreElements())
                System.out.println("servlets \t"+e.nextElement());
            /*e=context.getAttributeNames();
            while(e.hasMoreElements())
                System.out.println("AttributeNames \t"+e.nextElement());
            e=request.getParameterNames();
            while(e.hasMoreElements())
                System.out.println("ParameterNames \t"+e.nextElement());
            System.out.println("getContextPath "+request.getContextPath());
            System.out.println("getRequestURI"+request.getRequestURI());
            response.setContentType("text/xml+svg");
            PrintWriter out = response.getWriter();
            HttpSession httpSession=request.getSession();
            System.out.println("getQueryString"+httpSession);
            if(httpSession!=null && request.getRequestURI().endsWith("wafermap.svg"))
                /*e=httpSession.getAttributeNames();
                while(e.hasMoreElements())
                    System.out.println("httpSession AttributeNames \t"+e.nextElement());
                SVGProducer svgProducer=(SVGProducer)httpSession.getAttribute("waferMap");
                out.print(svgProducer.getSVGView());
            else if(httpSession!=null && request.getRequestURI().endsWith("hardware.svg"))
                SVGProducer svgProducer=(SVGProducer)httpSession.getAttribute("hardwareBean");
                out.print(svgProducer.getSVGView());
            else if(httpSession!=null && request.getRequestURI().endsWith("geometry.svg"))
                SVGProducer svgProducer=(SVGProducer)httpSession.getAttribute("geometryBean");
                out.print(svgProducer.getSVGView());
            else
                try
                    java.io.BufferedReader br=new java.io.BufferedReader(new java.io.FileReader("./webapps"+request.getRequestURI()));
                    String line=null;
                    while((line=br.readLine())!=null)
                        out.println(line);
                    br.close();
                catch(java.io.IOException ioe)
                    System.out.println("ioe:"+ioe.getMessage());
            out.close();
        /** Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
            processRequest(request, response);
        /** Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
            processRequest(request, response);
        /** Returns a short description of the servlet.
        public String getServletInfo()
            return "SVG graphics handler";
    }And any jsf component that implements
    * SVGProducer.java
    * Created on June 3, 2004, 9:09 PM
    package com.hypernex.xml.svg;
    * @author  hyperdev
    public interface SVGProducer
        public String getSVGView();
    }such as
    public class WaferMap extends Object implements com.hypernex.xml.svg.SVGProducer
        protected void generateSVGWafermap(java.sql.ResultSet resultSet)
            //FacesContext context = FacesContext.getCurrentInstance();
            //context.
            //Create an svg graph of the equation.
            org.apache.batik.dom.svg.SAXSVGDocumentFactory svgFactory=new org.apache.batik.dom.svg.SAXSVGDocumentFactory("org.apache.xerces.parsers.SAXParser");
            org.apache.batik.dom.svg.SVGDOMImplementation svgDOMImplementation=new org.apache.batik.dom.svg.SVGDOMImplementation();
            org.w3c.dom.DocumentType dt=null;//svgDOMImplementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN",f.toURI().toString());
            //System.out.println(dt);
            org.w3c.dom.svg.SVGDocument svgOMDocument=null;
            try
                System.out.println("dir "+(new java.io.File(".")).toURI().toString());
                java.io.File f=new java.io.File("./webapps/jsf-wita/siteadmin/templates/wafermap-template.svg");
                svgOMDocument=(org.w3c.dom.svg.SVGDocument)svgFactory.createDocument(f.toURI().toString(), new java.io.FileInputStream(f));//new org.apache.batik.dom.svg.SVGOMDocument(dt, (org.w3c.dom.DOMImplementation)svgDOMImplementation);
                org.w3c.dom.svg.SVGSVGElement root=svgOMDocument.getRootElement();
                org.w3c.dom.svg.SVGGElement visuals=(org.w3c.dom.svg.SVGGElement)svgOMDocument.getElementById("visuals");
                //visuals.getFirstChild().setNodeValue(Double.toString(xMin));
                //resultSet.beforeFirst();
                while(resultSet.next())
                    org.apache.batik.dom.svg.SVGOMRectElement rect=new org.apache.batik.dom.svg.SVGOMRectElement("", (org.apache.batik.dom.AbstractDocument)svgOMDocument);
                    rect.setAttribute("fill", "teal");
                    rect.setAttribute("stroke", "teal");
                    rect.setAttribute("transform", "scale(1, -1)");
                    rect.setAttribute("stroke-width", "1");
                    double x=50+100.0*(resultSet.getDouble("X")-2.5)/300.0;
                    double y=100.0*((resultSet.getDouble("Y")-2.0)/300.0-0.5);
                    //System.out.println(x+" "+y);
                    rect.setAttribute("x", Double.toString(x)+"%");
                    rect.setAttribute("y", Double.toString(y)+"%");
                    rect.setAttribute("width", "10");
                    rect.setAttribute("height", "8");
                    visuals.appendChild(rect);
                javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance();
                javax.xml.transform.Transformer intermediateTransformer=tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("./webapps/jsf-wita/stylesheets/identity.xsl"));
                java.io.CharArrayWriter caw=new java.io.CharArrayWriter();
                intermediateTransformer.transform(new javax.xml.transform.dom.DOMSource(svgOMDocument), new javax.xml.transform.stream.StreamResult(caw));
                svgView=caw.toString();
            catch(java.sql.SQLException sqle)
                System.out.println("sqle err: "+sqle.getMessage());
            catch(javax.xml.transform.TransformerConfigurationException tce)
                System.out.println("tce err: "+tce.getMessage());
            catch(javax.xml.transform.TransformerException te)
                System.out.println("te err: "+te.getMessage());
            catch(java.io.FileNotFoundException fnfe)
                System.out.println("fnfe:"+fnfe.getMessage());
            catch(java.io.IOException ioe)
                System.out.println("io:"+ioe.getMessage());
        public String getSVGView()
            return svgView;
        private String svgView="";of course with jpg or other binary formats you would need to use a byte array instead of a string. Note that my example does take a template svg file which holds all the static parts and positions for dynamic parts, gets any changes from the data in a database, and creates an in memory svg to go to the client with any changes since the last request.
    On a jsf/jsp/html page where there is
    <embed src="../wafermap.svg" align="left" width="400" height="400" ...the server will supply the graphic via the SessionServlet

  • How can we customize notification jsp according to connected user?

    We need to customize notification jsp according to connected user.
    we are trying get user method of (IWorkflowContext)httpSession.getAttribute("workflowContext")
    but (IWorkflowContext)httpSession.getAttribute("workflowContext") returrn null
    Jdev 10133 and soa suite 10131 on windows.
    our code fragment is
    HttpSession httpSession = request.getSession(false);
    if (httpSession != null) {
    IWorkflowContext ctx = (IWorkflowContext)httpSession.getAttribute("workflowContext");
    try
    if (ctx != null) {
    String bpmUser = ctx.getUser();
    out.println( bpmUser );
    else
    out.println("authFailed dididididi");
    Thanks for your help...

    Infact we need to Change Format/data of the pdf file wich comes with Workflow Notification PO "Response Required for PO Approval".
    I the pdf file attached is generated by "PO Output for Communication" Concurrent Program.
    Executable is "POXPOPDF" Execution File name is "PoGenerateDocumentCP" which is a java program.
    This prgram uses the following files to generate pdf output of draft PO output.
    DATA FILE:
    PO_STANDARD_PO.xml
    PO_STANDARD_PO.xsd
    TEMPLATE:
    PO_STANDARD_XSLFO.xsl
    I need to know any visual layout editor available to change contents/layout/data of this pdf.
    Regards,
    Usman
    Edited by: user10518960 on 01-Feb-2013 07:18

  • Send some atributes from a Servlet to a JSP program

    Hi all,
              I am quite new to JSP programming and am facing a problem. I have a
              Servlet code which is supposed to send some attributes to a JSP, which
              will display the attribute that has been passed through the Servlet.
              the Servlet code to do so is,
              request.setAttribute("emailtxt","emailNewTxt");
              RequestDispatcher rd=request.getRequestDispatche("/emailChangeSuc.jsp");
              rd.forward(request,response);
              on the JSP side, I am reciving this attribute in the following way,
              <body>
              <%@content_type="text/html"%>
              <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>
              and am displaying the value in this way
              <b><%=emailTxt%>
              but I am getting an error
              "non-static method getAttribute(java.lang.String) cannot be referenced
              from a static context
              probably occurred due to an error in /emailChangeSuc.jsp line 9:
              <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>"
              Please help me solve this problem.
              Thanks in anticipation,
              Rajiv.
              

    "Rajiv" == Rajiv <[email protected]> writes:
                        Rajiv> Hi all,
              Rajiv> I am quite new to JSP programming and am facing a problem. I have a
              Rajiv> Servlet code which is supposed to send some attributes to a JSP, which
              Rajiv> will display the attribute that has been passed through the Servlet.
              Rajiv> the Servlet code to do so is,
              Rajiv> {
              Rajiv> request.setAttribute("emailtxt","emailNewTxt");
              Rajiv> RequestDispatcher rd=request.getRequestDispatche("/emailChangeSuc.jsp");
              Rajiv> rd.forward(request,response);
              Rajiv> }
              Rajiv> on the JSP side, I am reciving this attribute in the following way,
              Rajiv> <body>
              Rajiv> <%@content_type="text/html"%>
              Rajiv> <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>
              Rajiv> and am displaying the value in this way
              Rajiv> <b><%=emailTxt%>
              Rajiv> but I am getting an error
              Rajiv> "non-static method getAttribute(java.lang.String) cannot be referenced
              Rajiv> from a static context
              Rajiv> probably occurred due to an error in /emailChangeSuc.jsp line 9:
              Rajiv> <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>"
              First of all, you put the attribute into the request, but you're trying to read
              it from the session. Change it to "request.getAttribute(...".
              Second, your compile error is stating that the "getAttribute()" method of
              HttpSession is not a static method. If you really needed to reference the
              session, it would just be "session". Changing to "request" as in the first
              point, will avoid this problem.
              Third, remove the "!" from the scriptlet which declares and sets the "emailTxt"
              variable. That makes it declare an instance variable instead of a local
              variable. That will cause numerous problems with this.
              ===================================================================
              David M. Karr ; Java/J2EE/XML/Unix/C++
              [email protected] ; SCJP; SCWCD
              

  • How to show a PDF with a JSF jsp.

    Hello,
    I want to show a PDF in a JSF jsp.
    I'm a newbie with this, and don't know where to look for information about that.
    Any example on the web ?
    Thanks in advance

    I think you will need to eventually get it to the HTML <object> tag anyway.
    <OBJECT data="yourPDFhere.pdf" type="????""/>
    and to get the byte[] to the client you may need to make a Servlet to respond to *.pdf requests and feed the correct session 'in memory' pdf out the stream.
    Here is an example from some svg 'in memory' per session I was testing:
    * SessionServlet.java
    * Created on June 3, 2004, 12:09 AM
    package com.hypernex.xml.svg;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * @author  Roger I Martin, PhD
    * @version
    public class SessionServlet extends HttpServlet
        /** Initializes the servlet.
        public void init(ServletConfig config) throws ServletException
            super.init(config);
        /** Destroys the servlet.
        public void destroy()
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
            ServletContext context=getServletContext();
            java.util.Enumeration e=context.getServlets();
            while(e.hasMoreElements())
                System.out.println("servlets \t"+e.nextElement());
            /*e=context.getAttributeNames();
            while(e.hasMoreElements())
                System.out.println("AttributeNames \t"+e.nextElement());
            e=request.getParameterNames();
            while(e.hasMoreElements())
                System.out.println("ParameterNames \t"+e.nextElement());
            System.out.println("getContextPath "+request.getContextPath());
            System.out.println("getRequestURI"+request.getRequestURI());
            response.setContentType("text/xml+svg");
            PrintWriter out = response.getWriter();
            HttpSession httpSession=request.getSession();
            System.out.println("getQueryString"+httpSession);
            if(httpSession!=null && request.getRequestURI().endsWith("wafermap.svg"))
                /*e=httpSession.getAttributeNames();
                while(e.hasMoreElements())
                    System.out.println("httpSession AttributeNames \t"+e.nextElement());
                SVGProducer svgProducer=(SVGProducer)httpSession.getAttribute("waferMap");
                out.print(svgProducer.getSVGView());
            else if(httpSession!=null && request.getRequestURI().endsWith("hardware.svg"))
                SVGProducer svgProducer=(SVGProducer)httpSession.getAttribute("hardwareBean");
                out.print(svgProducer.getSVGView());
            else if(httpSession!=null && request.getRequestURI().endsWith("geometry.svg"))
                SVGProducer svgProducer=(SVGProducer)httpSession.getAttribute("geometryBean");
                out.print(svgProducer.getSVGView());
            else
                try
                    java.io.BufferedReader br=new java.io.BufferedReader(new java.io.FileReader("./webapps"+request.getRequestURI()));
                    String line=null;
                    while((line=br.readLine())!=null)
                        out.println(line);
                    br.close();
                catch(java.io.IOException ioe)
                    System.out.println("ioe:"+ioe.getMessage());
            out.close();
        /** Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
            processRequest(request, response);
        /** Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
            processRequest(request, response);
        /** Returns a short description of the servlet.
        public String getServletInfo()
            return "SVG graphics handler";
    }

  • DataProvider not called on every render?

    I'm using JDev 10g preview. In the documentation for Data Binding, it says that a <method> specified in a <provider> tag "will be called once each time the page renders", but I don't think this is what I'm seeing.
    I will post my page code and the provider method below. What I'm trying to accomplish is that, if the 'pageId' parameter is not present or has an invalid value, and the bean has not already been initialized, an error message displays. If the 'pageId' is present, it should be used to (re)initialize the bean.
    I've put an output line ('Informant') at the top of the method call that returns the bean, but it's only printing when I first call the page (when I generally have not yet specified a 'pageId' parameter), not when I issue subsequent requests with a 'pageId' parameter. That is, I right-click on the page in JDev and run; debug line is printed and the page comes up with no parameter in the URL and prints the error message. Then, I add the '?pageId=1' and resubmit the request (hit enter) and the debug line is not printed and the page still renders with the error message.
    <?xml version="1.0" encoding="windows-1252"?>
    <page xmlns="http://xmlns.oracle.com/uix/controller"
          xmlns:ui="http://xmlns.oracle.com/uix/ui"
          xmlns:ctrl="http://xmlns.oracle.com/uix/controller"
          xmlns:html="http://www.w3.org/TR/REC-html40" expressionLanguage="el">
        <content>
            <dataScope xmlns="http://xmlns.oracle.com/uix/ui">
                <provider>
                    <data name="pageBean">
                        <method class="com.avega.portlets.view.BeanProvider"
                                method="getPageBean"/>
                    </data>
                </provider>
                <contents>
                    <document>
                        <metaContainer>
                            <head title="Key Indicators Portlet"/>
                        </metaContainer>
                        <contents>
                            <body>
                                <contents>
                                    <tableLayout borderWidth="1"
                                                 rendered="${ not pageBean.inErrorState }">
                                        <contents>
                                            <rowLayout>
                                                <contents>
                                                    <include node="${ctrl:parsePage(uix,'controlView')}"/>
                                                    <include node="${ctrl:parsePage(uix,'displayLayout')}"/>
                                                </contents>
                                            </rowLayout>
                                        </contents>
                                    </tableLayout>
                                    <styledText text="${ pageBean.errorString }"
                                                rendered="${ pageBean.inErrorState }"/>
                                </contents>
                            </body>
                        </contents>
                    </document>
                </contents>
            </dataScope>
        </content>
        <handlers>
            <event name="hide show">
                <set target="${uix.pageState}" property="${param.source}"
                     value="${param.event}"/>
            </event>
        </handlers>
    </page>Here is the method:
         public static Object getPageBean( RenderingContext context, String namespace, String name ) {
              Informant.debug( "BeanProvider.getPageBean" );
              BajaContext bajaContext = BajaRenderingContext.getBajaContext( context );
              HttpSession httpSession = bajaContext.getServletRequest().getSession();
              boolean newPageBean = false;
              PageBean pageBean = (PageBean)httpSession.getAttribute( PAGE_BEAN_ATTRIBUTE );
              if ( pageBean == null ) {
                   pageBean = new PageBean();
                   pageBean.setHttpSession( httpSession );
                   httpSession.setAttribute( PAGE_BEAN_ATTRIBUTE, pageBean );
                   newPageBean = true;
              HttpServletRequest request =  bajaContext.getServletRequest();
              String pageId = request.getParameter(ViewConstants.PARAM_PAGEID);
              if ( newPageBean || !Strings.isNullOrEmpty( pageId ) ) {
                   pageBean.setPageId( pageId );
                   try {
                        pageBean.initialize();
                        pageBean.setControlViewBean(
                             (PanelBean)pageBean.getPanelBeansByPortletPanel().get(
                                  pageBean.getPortletPage().getDisplayedControl()  ));
                   } catch ( NullPointerException npe ) {
                        pageBean.setInErrorState(true);
                        pageBean.setErrorString("Unable to initialize PageBean. "+
                             "'pageId' is probably null or specified a non-existant Page.");
              return pageBean;
         }Here is the server log:
    03/11/18 16:52:32 Requested page = Page[name=page]
    03/11/18 16:52:36 Rendering page = Page[name=page]
    03/11/18 16:52:38 BeanProvider.getPageBean
    03/11/18 16:52:47 Requested page = Page[name=page]
    03/11/18 16:52:47 Event = null
    03/11/18 16:52:47 Parameter pageId=1
    03/11/18 16:52:47 Rendering page = Page[name=page]

    Hmmm... I tried a simple experiment with the code provided below, and in this case I /do/ see the println for every request. So there must be something in the code I posted above that is keeping the provider from being called. Any idea what it might be?
    <?xml version="1.0" encoding="windows-1252"?>
    <page xmlns="http://xmlns.oracle.com/uix/controller"
          xmlns:ui="http://xmlns.oracle.com/uix/ui"
          xmlns:ctrl="http://xmlns.oracle.com/uix/controller"
          xmlns:html="http://www.w3.org/TR/REC-html40"
          expressionLanguage="el">
        <content>
            <dataScope xmlns="http://xmlns.oracle.com/uix/ui">
                <provider>
                    <data name="testBean">
                        <method class="uix.test.BeanProvider"
                                method="getTestBean"/>
                    </data>
                </provider>
                <contents>
                    <document>
                        <contents>
                            <body>
                                <contents>
                                            <styledText text="${ testBean }" />
                                </contents>
                            </body>
                        </contents>
                    </document>
                </contents>
            </dataScope>
        </content>
        <handlers>
            <!-- Add EventHandlers (<event> elements) here  -->
        </handlers>
    </page>
    package uix.test;
    import oracle.cabo.ui.RenderingContext;
    public class BeanProvider  {
         public BeanProvider() {
         public static Object getTestBean( RenderingContext context, String namespace, String name ) {
              System.out.println( "BeanProvider.getTestBean" );
              return new Object() {
                   public String toString() {
                        return "message";

Maybe you are looking for