Share variables between JSP and Classes

Hello !
Is there any way to share the same variables between JSP�s and Classes?
For example...
I have 20 variables in a JSP page (with values, like constants...) and I want to view their contents inside the classes...
Is there any way? Maybe a import or something like this...
Thanks,
Igor.

If you search the forums you will find many answers to your questions. You can also try the servlet and JSP short courses listed below;
Here is lthe link that will take you to the Java.sun.com Tutorial pages.
http://developer.java.sun.com/developer/onlineTraining/
Here is a tutorial on Servlets
http://developer.java.sun.com/developer/onlineTraining/Servlets/Fundamentals/contents.html
Here is the tutorial on the JSP
http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html

Similar Messages

  • How to share variable between jsp and JSF?

    hi:
    I have code :
    <h:dataTable binding="#{Tables.dataTable}" value="#{Tables.query}" var="currentRow">
    <h:column>
    <h:outputText value="#{currentRow['factorycode']}"/>
    </h:column>
    <%
    //here I want get upon variable currentRow and process some field.
    // but how java code I can get the currentRow,
    //currentRow is a ResultSet object
    %>
    </h:dataTable>
    thanks

    EL cannot pick up scripting variables. It picks up attributes from scope only.
    Similarly it doesnt set any scripting variables too.
    <%
                  int g_nAge=12;
                  pageContext.setAttribute ("g_nAge", new Integer(g_nAge));
    %>
    ${g_nAge}cheers,
    ram.

  • How to deliver variable between jsp and EL ?

    this is the code of my *.jsp
    <%
    int g_nAge=12;
    %>
    ${g_nAge}
    I suppose that "12" is showed in my web-page,but actually I see nothing.
    This is an example in my jsp book showing the delivering variable between JSP and EL !
    how can it do that ?

    EL cannot pick up scripting variables. It picks up attributes from scope only.
    Similarly it doesnt set any scripting variables too.
    <%
                  int g_nAge=12;
                  pageContext.setAttribute ("g_nAge", new Integer(g_nAge));
    %>
    ${g_nAge}cheers,
    ram.

  • How can I pass a variable between JSP and Role Form

    I need to pass a variable from (a copy of) applicationmodify.jsp to the IDM Role Form so that the variable is available within the Role Form at display. We've tried getAttribute and setAttribute modifying both the Role Form and the applicationmodify JSP and can get the form to the role form but not accessible but have had no other success. Has anyone had any success in doing this? Any suggestions would be appreciated.

    if by _root level you mean you're loading something into
    _level0 you can't won't be able to use the localconnection. the
    sharedobject is your only option.

  • Can I share Attributes/Variables between 2 different Class Driver Sessions?

    I am designing a Simulator of Instrumentation following these steps:
    1) re-programming, re-compiling, and re-building the DLLs from the advanced class simulation drivers included in IVI Driver Toolset 2.0 using LabWindows/CVI 7.0;
    2) then i create a VI in LabVIEW 7.0 which calls an IVI Class Driver obtaining the desired simulated output data.
    My problem is that I need to share variables between different DLLs in LabVIEW.
    I want to simulate a circuit which consists of a battery and a resistor. I've got 2 instruments: a DC Power Supply and a Digital Multimeter.
    The DC Power Supply acts as the battery providing a certain voltage level, and the Multimeter measures the Voltage and the Current in the resistor.
    I've designed a VI in LabVIEW which uses 2 different sessions: one which calls the class driver IviDCPwr, and the other one which calls IviDmm.
    I wish to be able to access the attributes from "nisDCPwr.c" in the file "nisDmm.c".
    For example, to write a line like this:
    Ivi_GetAttributeViReal64 (ViSession vi, ViConstString channelName, NISDCPWR_ATTR_MEASUREMENT_BASEV, 0, &reading));
    inside the source code "nisDmm.c" of the advanced class simulation driver.
    The problem is that the only ViSession accessible from nisDmm is the handle from the Digital Multimeter, but not from DC Power Supply.
    Would this be possible? Is it "legal"?
    I've tried another approach through the declaration of external variables, but unfortunately I get a run-time error in LabVIEW.
    The only solution I've found is using auxiliary files going between, through the functions included in the Low Level I/O Library .
    Nevertheless, the solution proposed above would result much more convenient, faster and safer in my application.
    I hope everyone has understood my question, and anyone can help.
    THANK YOU VERY MUCH FOR YOUR TIME!!!

    Doesn't anyone have an answer?
    Or any proposal?
    Or even a clue?
    THANKS!

  • Using HttpServletRequest object to share variables between static methods.

    Does anyone know of the overhead/performance implications of using the HttpServletRequest object to share variables between a static method and the calling code?
    First, let me explain why I am doing it.
    I have some pagination code that I would like to share across multiple servlets. So I pulled the pagination code out, and created a static method that these servlets could all use for their pagination.
    public class Pagination {
         public static void setPagination (HttpServletRequest request, Config conf, int totalRows) {
              int page = 0;
              if (request.getParameter("page") != null) {
                   page = new Integer(request.getParameter("page")).intValue();
              int articlesPerPage = conf.getArticlesPerPage();
              int pageBoundary = conf.getPageBoundary();
                int numOfPages = totalRows / articlesPerPage;  
                // Checks if the page variable is empty (not set)
                if (page == 0 || (page > numOfPages && (totalRows % articlesPerPage) == 0 && page < numOfPages + 1)) {    
                 page = 1;  // If it is empty, we're on page 1
              // Ex: (2 * 25) - 25 = 25 <- data starts at 25
             int startRow = page * articlesPerPage - (articlesPerPage);
             int endRow = startRow + (articlesPerPage);           
             // Set array of page numbers.
             int minDisplayPage = page - pageBoundary;
             if (minDisplayPage < 1) {
                  minDisplayPage = 1;     
             int maxDisplayPage = page + pageBoundary;
             if (maxDisplayPage > numOfPages) {
                  maxDisplayPage = numOfPages;     
             int arraySize = (maxDisplayPage - minDisplayPage) + 1;
             // Check if there is a remainder page (partially filled page).
             if ((totalRows % articlesPerPage) != 0) arraySize++;
             // Set array to correct size.
             int[] pages = new int[arraySize];
             // Fill the array.
             for (int i = 1; i <= pages.length; i++) {
                  pages[i - 1] = i;
             // Set pageNext and pagePrev variables.
             if (page != 1) {
                  int pagePrev = page - 1;
                  request.setAttribute("pagePrev", pagePrev);
             if ((totalRows - (articlesPerPage * page)) > 0) {
                 int pageNext = page + 1;
                 request.setAttribute("pageNext", pageNext);
             // These will be used by calling code for SQL query.
             request.setAttribute("startRow", startRow);
             request.setAttribute("endRow", endRow);
             // These will be used in JSP page.
             request.setAttribute("totalRows", totalRows);
             request.setAttribute("numOfPages", numOfPages);
             request.setAttribute("page", page);
             request.setAttribute("pages", pages);          
    }I need two parameters from this method (startrow and endrow) so I can perform my SQL queries. Since this is a multithreaded app, I do not want to use class variables that I will later retrieve through methods.
    So my solution was to just set the two parameters in the request and grab them later with the calling code like this:
    // Set pagination
    Pagination.setPagination(request, conf, tl.getTotalRows());
    // Grab variables set into request by static method
    int startRow = new Integer(request.getAttribute("startRow").toString());
    int endRow = new Integer(request.getAttribute("endRow").toString());
    // Use startRow and endRow for SQL query below...Does anyone see any problem with this from a resource/performance standpoint? Any idea on what the overhead is in using the HttpServletRequest object like this to pass variables around?
    Thanks for any thoughts.

    You could either
    - create instance vars in both controllers and set them accordingly to point to the same object (from the App Delegate) OR
    - create an instance variable on the App Delegate and access it from within the view controllers
    Hope this helps!

  • Difference between JSP and ASP

    Whatz the diff between JSP and ASP

    Hello msdnexpert,
    Active Server Pages (ASP) allows you to build rich, data driven, dynamic complex applications. ASPs are written in Perl, VBScript, C/C++. They run on machines running Microsoft Windows. With ASP, an HTML page on a web server can contain snippets of embedded code. This code is read and executed by the web server before it sends the page to the client (usually a browser such as Netscape Navigator or Microsoft's Internet Explorer.) For more information on ASP see:
    http://www.microsoft.com/workshop/server/default.asp
    or
    http://www.activeserverpages.com
    Java Server Pages (JSP) also allows you to build rich, data driven, dynamic complex applications. JSPs are written in Java. They run on any Java enabled machine, including Solarlis, Windows, Linux, and Mac OS. JSPs also makes available all of Java's industrial strength security for free. JSPs uses a syntax similar to ASP except that the scripting language is Java. Unlike ASP, JSP is an open standard implemented dozen of venders across all platforms. JSPs are closely tied to servlets because a JSP page is transformed into a servlet as part of its execution. For more information on JSP see:
    http://java.sun.com/products/jsp
    A servlet is a generic server extension -- a Java class that can be loaded dynamically to extend the functionality of a server. Servelets are commonly used with web servers, where they can take the place of CGI scripts. A servlet is similar to a proprietary server extension, except that it runs inside a Java Virtual Machine on the server side, so it is safe and portable. Servlets operate solely within the domain of the server: Unlike Applets, they do not require support for Java in the web browser.
    Unlike CGI, which must use multiple process to handle separate programs and/or separate requests, servlets can all be handled by separate threads within the same process or by threads within multiple processes spread across a number of back end servers. This means that servlets are also efficient and scalable. Because servlets run with bi-directional communication to the web server, they can interact very closely with the server to do things that are not possible with CGI. Another advantage of servlets is that they are portable: Both across operating systems and across web servers.
    Resources used in researching this response:
    Java Servlet Programing 2nd Ed by Jason Hunter with William Crawford.
    http://press.oreilly.com/jservlet2.html
    http://oreilly.com/catalog/jservlet2/
    -Merwyn,
    Developer Technical Support,
    http://www.sun.com/developers/support.

  • Communication between jsp and abstractportalcomponent

    Hello All
    Communication between jsp and abstractPortalComponent.
    jsp contains one input text field and one submit button.
    when the user clicks on submit button it will call the component and that input value will
    display in same jsp page.
    how this communication will happen?
    Rgrds
    Sri

    Hi Srikanth,
    In the JAVA File, 
    OnSubmit Event,
    String inputvalue ;
    InputField myInputField = (InputField) getComponentByName("Input_Field_ID");
    if (myInputField != null) {
                   inputvalue = myInputField.getValueAsDataType().toString();
    request.putValue("textvalue", inputvalue);
    request is IPORTALCOMPONENTREQUEST Object.
    In JSP File,   to retreive the value,
    <%
    String  textstring = (String) ComponentRequest.getValue("textvalue");
    %>
    In PORTALAPP.XML File,
    <component name="component name">
          <component-config>
            <property name="ClassName" value="classname"/>
            <property name="SafetyLevel" value="no_safety"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
    Using the code above, You can pass and read values between abstract portal component and Jsp Page.
    Instead of this, I suggest you to use JSPDYNPAGE Component for Data Exchange.
    Check the [Link|http://help.sap.com/saphelp_nw2004s/helpdata/de/ce/e0a341354ca309e10000000a155106/frameset.htm].
    Hope this helps you.
    Regards,
    Eben Joyson

  • How to share files between pc and mac via external hard drive

    how can i share my files(mp3,mp4,documents) from my harddisk with mac. i am a new mac user and i have a harddisk of NTFS format(as i was a pc user).I learned that mac supports FAT32 format and therefore i can't write data on my external hard drive.
    but, reading a section of OSX yosemite(under compatibility) it is said that now we can easily share files between pc and mac.
    So please suggest me easier way that how can i share files between macs and pc as my friends uses pc and in future i really want to share my data with them without any hustle and i dont wanna loose my data in future

    You can format the HDD to a common one like ExFAT or Fat32 but a reformat will delete all data off of the HDD.
    Your other option is to use a third party software such as Paragon or Tuxera that will allow you to write to a NFTS formatted HDD.
    Ciao.

  • What's the difference between jsp and jsf?

    who can tell me what's the difference between jsp and jsf?
    I'm puzzled when I found some of the technology in jsp is so similar to the ones in jsp( javaserver page)

    Hi,
    Find the difference between JSP and JSF
    1. A developer has more control with JSP, but (should) get easier development with JSF
    2. Event handling is done differently in JSP (HTTP) and JSF (Java)
    3. The UI is designed differently (or should be at least) with JSP (markup) and JSF (components).
    4. The end product should also be defined differently - JSP page versus a JSF application.
    Is this the only thing that is need to make a decision for either or? Probably not. There are other pieces that need to be taken in account when deciding which technology to use - tools support, enough components, type of application etc.... At this point there are not enough JSF components (although there are some interesting projects underway - Ajaxfaces, Myfaces, ADF Faces, and WebChart 3d) and enterprise tools support is still limited to a few tools vendor. Looking at our ADF Faces components they are currently available as early access (not production) and demands for these components are stacking up, literally, outside my office doorstep. Although I would love to make them production - now! - it is not a viable solution since we are still checking features and fixing critical bugs.
    All this combined - not enough enterprise level components in production, lacking tools support etc... - leave customers in a vacuum where the decision is either to continue with JSP, since it is mature and has a wide developer base, or move forward with JSF not sure if the support, or the developers will be there. This is particularly sensitive to customers that need to get started now and be production by summer.
    If you are in this vacuum here are some key points promoting JSF:
    1. Fundamental unit is the Component
    2. Built in event and state management
    3. Component sets can be provided by any vendor
    4. Closer to ASP.Net or Swing development
    5. Choice of UI technology
    6. Scale up (rich clients)
    7. Scale down (mobile devices)
    8. Built into J2EE containers in J2EE 5.0 (tentative)

  • Does anyone know if there is a way to share files between Mavericks and Mac OS 9.1 operating system?

    Does anyone know if there is a way to share files between Mavericks and Mac OS 9.1 operating system? When I try to connect from my iMac I get a window that says "The version of the server you are trying to connect to is not supported." Is there a work-around to this problem or is it just not possible? It would be largly appriciated for a solutin beings my business is a small town newspaper, and we have some important files on the older computer that need to be acessed daily.

    Actually to share files between OS 8-9 and OS X, all versions, is quite easy from what I read. Look here for some details.
    http://reviews.cnet.com/8301-13727_7-20003464-263.html
    And here.
    https://www.google.com/search?q=file+sharing+Mac+OS+9.x&oq=file+sharing+Mac+OS+9 .x&aqs=chrome..69i57.20706j0j1&sourceid=chrome&ie=UTF-8
    Or since both OS 9 and OS X can do SMB Windows sharing you could use that protocol to share files from one to the other.
    Doesn't really matter what OS you are using. Mac OS/OS X shar files with Windows computers of all types and versions of Windows so the same applies for the different versions of Mac OS/OS X.
    Each Operating System takes care of reading and writing files to there respective file formats of the hard drives so that does not have to be the same. They both just have to be able to do Ethernet with the same files sharing protocol.

  • Difference between JSP and JSF

    What is the difference between JSP and JSF?
    Is it necessary to learn JSP before starting with JSF?

    JSP is a view technology providing a template to write plain HTML/CSS/JS in. JSP supports Java based taglibs to generate output and/or control the page flow dynamically. A well known example is JSTL. JSP also supports access to backend data with help of EL (Expression Language).
    JSF is a component based MVC framework which provides taglibs for use in JSP, the JSF core tags in <f:xxx> and the JSF HTML tags in <h:xxx>. Those tags generate HTML output and are tied to JSF component tree in the server memory so that the FacesServlet can work on them to gather request parameters, validate/convert them, update the model values (javabean properties), invoke some actions (javabean action methods) and render the response.
    You can use JSF on top of either JSP or Facelets. Facelets is another view technology. JSP is ancient and has its shortcomings when JSF comes into picture. Facelets is designed with JSF in mind and much more well-suited for it and provides great templating/composition capabilities to reuse specific groups of components without the need to wrap them in another custom component (so that you don't duplicate the same code over and over, e.g. label+input+message.

  • Passing values between jsp and php

    hi there, is it possible to pass values between jsp and
    php? i really need to find out the way if there is
    any. thanks in advance
    -azali-

    Yes, there are a few ways to do this.
    1) Think about using Cookies.
    2) Maybe use a Redirect passing the values in the Query string.
    3) Retain the data in a repository in the back end.
    4) Using Hidden fields within your pages.
    I am sure you can use these Idea's for a base to develop other methods on how to pass values back and forth from JSP -> PHP and vice versa.
    -Richard Burton

  • Connection Between JSP and PostgreSQL

    Hello all,
    Pls provide me some code about database connection between JSP and PostgreSQL.
    i need reference of PostgreSQL and JSP also.
    Thanking u,
    Ripon

    go to PostgreSQL website and download the JDBC or other connection and use it.
    Setup the connection from your controlpanel > ODBC data source if its win98 OS.

  • What's the difference between *.JSP and *.DO?

    Hi. I'm new to JSP programming and noticed that form actions call something like pageName.do -- what's the difference between the .JSP and .DO? When do you call one vs. the other? Thanks.

    A request including the jsp extension usually refers to a single JSP file on disk that will be loaded and rendered directly.
    A request including the do extension usually refers to a call into a special servlet that will redirect the request to another "controller" class which will in turn do some processing, and then load one or more JSP files to render the response.
    The commonest form of the latter is the usage in the Struts framework. The do extension is not mandatory, it just presents a convenient way to distinguish calls that should be handled by Struts from requests for JSPs and other content that are mostly handled by the container (e.g. Tomcat) directly.

Maybe you are looking for

  • TS4268 FaceTime not working on iPad 3 even after configuring DNS settings

    I'm having difficulty signing into iMessage and facetime on my new iPad. When i input my apple id and password it comes up with an error "The server encountered an error processing registration. Please try again later.". My ipad is currently connecte

  • 2 months with no dishwasher and counting - why did I buy a contract?

    I would really love to talk to someone at BBY that can help me.   Bought the extended warranty on an LG dishwasher which started throwing errors. Called GeekSquad.  They said they needed to dispatch, but that they do not service my area directly. (I

  • Slide show settings

    Is there a way to set times for individual photos? I want some to be on screen longer than others.

  • Can publish release build.

    I am getting this error on a project. Flash Builder could not publish the project source: null Does anyone have any ideas. The details is a java.lang.NullPointerException. Cheers Rob

  • Unschedule Local Process chain from meta chain

    Hi There, We have a meta chain, in which there are several local chains one for each process area. Due to a transport I have to unschedule one local chain and let the other local chains run. Please let me know what is best way to do it? Thanks, Raju