How to ask for a servlet response into a JSP?

Hi guys,
I have the following problem. I developed a servlet able to return a string with some information.
I would like to see this information from a JSP page. In other words, I would like to encapsule in the jsp page, the info requested to the servlet.
Is it possible? In this case the servlet returns a piece of HTML text. If there is a way, could it be possible to use the same mechanism for a JSP to ask a servlet to include a picture in the page?
Many thanks
/Massimo

maxqua72 wrote:
Hi guys,
I have the following problem. I developed a servlet able to return a string with some information.
I would like to see this information from a JSP page. In other words, I would like to encapsule in the jsp page, the info requested to the servlet.Just put the result in the request scope and forward the request to the JSP.
Is it possible? In this case the servlet returns a piece of HTML text. E.g.
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
    String result = "<b>result</b>";
    request.setAttribute("result", result);
    request.getRequestDispatcher("page.jsp").forward(request, response);
}page.jsp<p>Result is: ${result}</p>If the servlet actually writes HTML to its response (not so nice) then you can use <jsp:include/> to include it in your JSP page.
If you want to do it all asynchronously, then indeed consider AJAX.
If there is a way, could it be possible to use the same mechanism for a JSP to ask a servlet to include a picture in the page?Write an independent servlet for that. You may find this article useful: [http://balusc.blogspot.com/2007/04/imageservlet.html].

Similar Messages

  • How to ask for a number of copies in Finder Print?

    How to ask for a number of copies in Print Finder Items? Thanks.
    iBook G3 700   Mac OS X (10.4.8)   Still running a paperless office on my iBook! 120gig, 640RAM, 1440 x 900 2nd monitor! 500gig FW-HD!

    Here is a script that will create a "Run AppleScript" action in Automater that should do what you want. Just click on the link and hit the Run button in Script Editor.
    I wanted to get this too you fast so there is no error checking on the text entered into the dialog. Let me know if you want it added.
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">
    tell application "Automator"
    make new workflow
    -- Action 1
    add Automator action "Run AppleScript" to workflow 1
    set value of setting 1 of Automator action 1 of workflow 1 to "on run {input, parameters}
    tell application \"Finder\"
    activate
    set theFiles to input
    display dialog \"How many copies do you want\" default answer \"1\"
    set NumberOfCopies to text returned of the result as integer
    end tell
    repeat with aFile in theFiles
    repeat with j from 1 to NumberOfCopies
    tell application \"Finder\" to display dialog \"Printing copy \" & j & return & aFile giving up after 2
    tell application \"Finder\" to print aFile
    end repeat
    end repeat
    return input
    end run"
    end tell</pre>
    PowerBook 12"   Mac OS X (10.4.8)  

  • I have a mac OSX desktop version 10.6.8 and all of a sudden I can't get a full screen view in Safari when I ask for help the response is use the arrows on the top right of the screen ... I don't have them  ... can anyone help?

    I have a mac OSX desktop version 10.6.8 and all of a sudden I can't get a full screen view in Safari when I ask for help the response is use the arrows on the top right of the screen ... I don't have them  ... can anyone help?

    Hi Mary,
    I don't remember those arrows in 10.6, only 10.7 & up!?
    I have 10.6.8, as you do. To make your Safari full screen, make sure you have the left hand side of your safari page moved  all the way to the left.  Then move your cursor to the BOTTOM RIGHT CORNER of the safari page, and simply drag your page towards the lower right hand corner of the screen. NOTE: you will see a series of lines on the bottom right corner of the page, indicating where to place you cursor arrow.
    By wuzradioman here...
    https://discussions.apple.com/thread/4218928?start=0&tstart=0

  • How to ask for an array and how to save the values

    I'm supposed to be learning the differences between a linear search and a binary search, and the assignment is to have a user input an array and search through the array for a given number using both searches. My problem is that I know how to ask them how long they want their array to be, but I don't know how to call the getArray() method to actually ask for the contents of the array.
    My code is as follows:
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How long would you like the array to be?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            System.out.println("Please enter the first value of the array");
        public static void getArray(int List[], int arrayLength)
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter the next value for array");
                 List[i] = input.nextInt();
         public static void printArray(int List[])
             for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
    public class search
        public static int binarySearch(int anArray[], int first, int last, int value)
            int index;
            if(first > last) {
                index = -1;
            else {
                int mid = (first + last)/2;
                if(value == anArray[mid]) {
                    index = mid; //value found at anArray[mid]
                else if(value < anArray[mid]) {
                    //point X
                    index = binarySearch(anArray, first, mid-1, value);
                else {
                    //point Y
                    index = binarySearch(anArray, mid+1, last, value);
                } //end if
            } //end if
            return index;
        //Iterative linear search
        public int linearSearch(int a[], int valueToFind)
            //valueToFind is the number that will be found
            //The function returns the position of the value if found
            //The function returns -1 if valueToFind was not found
            for (int i=0; i<a.length; i++) {
                if (valueToFind == a) {
    return i;
    return -1;

    I made the changes. Two more questions.
    1.) Just for curiosity, how would I have referenced those methods (called them)?
    2.) How do I call the searches?
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How many values would you like the array to have?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            //Collects the array information
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter a value for array");
                 List[i] = input.nextInt(); 
            //Prints the array
            System.out.print("Array: ");
            for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
            //Asks for the value to be searched for
            System.out.println("What value would you like to search for?");
            int temp = input.nextInt();
            System.out.println(search.binarySearch()); //not working
    }

  • Ipod ask for passcode cannot get into ipod to unlock

    did recovery mode but it asks for passcode unable to put passcode into ipod to unlock

    Why are you unable to put in the passcode?  Does the iPod belong to someone else?

  • How to ask for a new feature in SBO

    Is there a way to ask for a new feature in SBO ? A page or procedure ? I client wants to do it through the proper channels.

    Hi......
    Take SDk help in terms of Addon in order to plug the new features......
    Regards,
    Rahul

  • How to ask for a CC Balance increase??

    Hey All!, I'm looking to get an increase to my credit card so I can actually utilize my card for intended purposes vs. having to constantly go in and pay on balances so that the credit utilization does not hurt my score. My scores just recently dropped because I had about $2000 hit my credit utilization when I was on vacation and forgot to pay before the statement hit which kind of put me over the edge to take action about it. Monthly Income $10,400Mortgage $2,000Auto Loan $420 $0 balance on revolving credit with a good pay history to which I generally never allow anything to hit the statement. I was young and dumb at one point and had everything maxed out and paid minimum payments but have been straight arrow for about 2 years. Outside of my home and auto I have zero debt. Prior to this balance credit utilization increase my scores were... Eq: 758 Trans: 791 Ex: 772 Now my scores are... Eq: 742 Trans: 776 Ex: 778 My credit card are as follows:Capital One - Limit: $3,500 - Member Date 2005American Express - $2,500 - Member Date 2015Bank Of America - $2,000 - Member Date 2006  What kind of increase should I ask for and what is the most effective way to do so? TIA!                   

    Mossburg031 wrote:
    Hey All!, I'm looking to get an increase to my credit card so I can actually utilize my card for intended purposes vs. having to constantly go in and pay on balances so that the credit utilization does not hurt my score. My scores just recently dropped because I had about $2000 hit my credit utilization when I was on vacation and forgot to pay before the statement hit which kind of put me over the edge to take action about it. Monthly Income $10,400Mortgage $2,000Auto Loan $420 $0 balance on revolving credit with a good pay history to which I generally never allow anything to hit the statement. I was young and dumb at one point and had everything maxed out and paid minimum payments but have been straight arrow for about 2 years. Outside of my home and auto I have zero debt. Prior to this balance credit utilization increase my scores were... Eq: 758 Trans: 791 Ex: 772 Now my scores are... Eq: 742 Trans: 776 Ex: 778 My credit card are as follows:Capital One - Limit: $3,500 - Member Date 2005American Express - $2,500 - Member Date 2015Bank Of America - $2,000 - Member Date 2006  What kind of increase should I ask for and what is the most effective way to do so? TIA!                   Cap One go to Services>More>Request Credit Line Increase, select card, answer questions  Amex go to More Options>Credit Management>Increase Line of Credit put in 4 digit number, answer questions 

  • How to ask for a new feature/function?

    I am having problems with iTunes, release 9.2.1(4), because of the way the popup menu is laid out. When I Control+click on the Podcast list the resulting popup menu lists 'Mark as played' at the very top. This changed sometime in the last several releases. It used to have 'Update podcast' at the top of the list.
    I am also having problems with my iPod 5G Video playlist. When I sync new podcast to the iPod they end up on the bottom of the list, but there are a few that I'd like at the very beginning. I highlight them then drag them with the mouse, but I can't get up to the top of the list for some reason. I can only get up as high as the 2nd item in the list. I think this is because the software doesn't account for the column headings.
    I'd like to ask that Apple's iTunes Software Engineers add both an 'undo' function to the Podcasts list and a function that lets me order some of my frequently used commands (like 'Update podcast') to this popup list. (I know I could try scripting, but I don't really have the time to learn another computing language.) I am specifically looking for something that allows for undoing things like marking all my podcasts as played when I really only wanted to do an update.
    I'd also like to ask that someone look into this issue of not being able to drag a podcast to the very beginning of the list so as to make it the new number one item.
    I'd like to do all these things, but I don't know if there is something I'm missing. If anyone knows how to get around these issues without having Apple reprogram iTunes please let me know.

    Click here and fill out the form.
    (53107)

  • Login screen does not ask for password when logging into user account

    This is an issue that did not immediately manifest itself after I have upgraded to Snow Leopard. I am not sure what exactly triggered it.
    Anyway, now at the login screen if I choose to login with my own user account, i.e. clicking on the icon associated to my user account, I am not prompted for the password and the system seems to start trying to login, as there is a discernible pause. Obviously that will fail, and I am returned to the login screen again.
    If I choose the other user option, as before I will be allowed to manually type in an user id and password, and using this way I am able to login into my own account (previously I only use this for logging in to the root account).
    Any idea on how I can make the field for typing in the password appear again? Thanks.

    Just to report that deleting /Library/Preferences/com.apple.loginwindow.plist did not help.
    Anyway I installed Snow Leopard again and the problem went away. Hope I will not do something that will trigger it again.

  • How to test for différent Select into a single PL/SQL block ?

    Hi,
    I am relatively new to PL/SQL and I am trying to do multiple selects int a single PL/SQL block. I am confronted to the fact that if a single select returns no data, I have to go to the WHEN DATA_NOT_FOUND exception.
    Or, I would like to test for different selects.
    In an authentification script, I am searching in a table for a USER ID (USERID) and an application ID, to check if a user is registered under this USERID for this APPLICATION.
    There are different possibilities : 4 possibilities :
    - USERID Existing or not Existing and
    - Aplication ID found or not found for this particular USERID.
    I would like to test for thes 4 possibilities to get the status of this partiular user regardin this application.
    The problem is that if one select returns no row, I go to the exception data not found.
    In the example below you see that if no row returned, go to the exception
    DECLARE
    P_USERID VARCHAR2(400) DEFAULT NULL;
    P_APPLICATION_ID NUMBER DEFAULT NULL;
    P_REGISTERED VARCHAR2(400) DEFAULT NULL;
    BEGIN
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
    :P39_TYPE_UTILISATEUR := 'USER_REGISTERED';
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    :P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND';
    END;I would like to do first this statement :
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID Then to do this one if the user is found :
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;etc...
    I basically don't want to go to the not found exception before having tested the 4 possibilities.
    Do you have a suggestion ?
    Thank you for your kind help !
    Christian

    Surely there are only 3 conditions to check?
    1. The user exists and has that app
    2. The user exists and doesn't have that app
    3. The user doesn't exist
    You could do this in one sql statement like:
    with mimic_data_table as (select 1 userid, 1 appid from dual union all
                              select 1 userid, 2 appid from dual union all
                              select 2 userid, 1 appid from dual),
    -- end of mimicking your table
             params_table as (select :p_userid userid, :p_appid appid from dual)
    select pt.userid,
           pt.appid,
           decode(min(case when dt.userid = pt.userid and dt.appid = pt.appid then 1
                           when dt.userid = pt.userid then 2
                           else 3
                      end), 1, 'User and app exist',
                            2, 'User exists but not for this app',
                            3, 'User doesn''t exist') user_app_check
    from   mimic_data_table dt,
           params_table pt
    where  pt.userid = dt.userid (+)
    group by pt.userid, pt.appid;
    :p_userid = 1
    :p_appid = 2
        USERID      APPID USER_APP_CHECK                 
             1          2 User and app exist   
    :p_userid = 1
    :p_appid = 3
        USERID      APPID USER_APP_CHECK                 
             1          3 User exists but not for this app
    :p_userid = 3
    :p_appid = 2
        USERID      APPID USER_APP_CHECK                 
             3          2 User doesn't exist  

  • Email keeps asking for me to sign into icloud

    I have an iPhone5 using OS 7.1.2 (I have not updated to OS8 yet).
    When clicking on the email icon, I get an opening page that has several email apps to choose from.  Since the only one I have on this list is iCloud, I fill in my Apple ID and PW.  It says it is already added to this phone.
    This is as far as I can go.  It worked earlier today, but tonight this has changed.
    Any suggestions on  how to get it to go to mail?
    Sue

    To change the iCloud ID you have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iPhone, then sign back in with the ID you wish to use.  If you don't know the password for your old ID, or if it isn't accepted, go to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • How to reference a DatabaseHandler servlet class from a jsp file in Tomcat

    Trying to create a database connection in the jsp file in webapps\project folder by referencing the DatabaseHandler class in webapps\project\WEB-INF\classes.
    Here is the code in the jsp to make the connection:
    DatabaseHandler db = new DatabaseHandler() ;
    String sql = "SELECT password FROM cms_users WHERE user =" + userName ;
    java.sql.ResultSet rs = db . selectQuery( sql ) ;
    Here is the DatabaseHandler class:
    import java.sql.*;
    public class DatabaseHandler
         // instance variables - replace the example below with your own
    private Connection connection;
         * Constructor for objects of class DatabaseHandler
         public DatabaseHandler()
    String url = "jdbc:odbc:javadatabase";
    // Load the driver to allow connection to the database
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    connection = DriverManager.getConnection( url );
    catch ( ClassNotFoundException cnfex )
    System.err.println( "Failed to load JDBC/ODBC driver." );
    cnfex.printStackTrace();
    System.exit( 1 ); // terminate program
    catch ( SQLException sqlex )
    System.err.println( "Unable to connect" );
    sqlex.printStackTrace();
    public ResultSet selectQuery( String query )
    Statement statement;
    ResultSet resultSet = null ;
    try
    statement = connection.createStatement();
    resultSet = statement.executeQuery( query );
    catch ( SQLException sqlex )
    sqlex.printStackTrace();
    System . exit( 1 ) ;
    return resultSet ;
    Here is the error i am getting when i try to run the jsp script:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 2 in the jsp file: /ValidateLogon.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\cms\ValidateLogon_jsp.java:47: cannot find symbol
    symbol : class DatabaseHandler
    location: class org.apache.jsp.ValidateLogon_jsp
    DatabaseHandler db = new DatabaseHandler() ;
    ^

    Just like in the class file you need to import any classes that you want to access in the JSP.
    http://java.sun.com/products/jsp/tags/11/syntaxref11.fm7.html

  • How to forward from a servlet to a (secured) jsp

    hi all
    actually i am trying to forward a request from a servlet to a jsp which is located in the WEB-INF-directory of the web-app...
    as i read in the docs the path in the getRequestDispatcher-method must start with a "/" so i tried to get a requestDispatcher-object from this path:
    /WEB-INF/secureJSP/abc.jsp...
    but all i get is a FileNotFoundException: no ressource "..." in the servlet context root "..."
    if i put the jsp in the web-app-root (like /abc.jsp) i am able to get a requestDispatcher-object without troubles...
    whats wrong? any ideas?
    tia
    sandro

    Hi
    Let me clarify this for you, Firstly as I said the WEB-INF directory is not accessible to the browser i.e a user couldn't possibly type in http://server-name:port-number/myapp/WEB-INF/test.jsp - This wouldn't work. But what you can do is forward a request to the jsp through a servlet using the RequestDispatcher.
    The RequestDispatcher object can be obtained in two ways. One is from the servletContext and the other is from the request. If it is obtained from the servletContext then the path is interpreted relative to the root of the web application. If it is got from the request without the "/" then the path is interpreted relative to the current request servicing resource.
    In your case get the RequestDispatcher from the ServletContext and provide the path as you have provided - assuming that WEB-INF directory is just below your myapp directory.
    Keep me posted on your progress & sorry for the confusion.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • I'm trying to setup my new iphone and the Apple ID it asks for is my friends old Apple ID that she no longer has access to. How can I fix this?

    I'm trying to setup my new iphone and the Apple ID it asks for is my friends old Apple ID that she no longer has access to. How can I fix this so I can use my new phone? The first step asks for my iCloud info but then asks for my friends after I agree to the terms.

    The iPhone is new, has never been used. When asked if I want to set it up as a new phone, restore from an iTunes backup, or my iCloud backup I selected iCloud. It then askes for me to sign in with my Apple ID, I then agree to the terms, then it asks for me to sign into my friends Apple ID. She and I have used each other's computers in the past so I assume this is where her information is coming from. The problem is she no longer had that email or Apple ID and has no way of gaining access to it and therefor I am unable to proceed.
    I suppose my question is, how can I remove her information from mine so I can setup my new phone using iCloud. Also, I have already checked my Apple ID online and nowhere on my account is her information listed.

  • How can I ask for things to add in the next ios update

    There are a few things I would like on my ipod touch as ios accesories.
    So how do ask for these things?

    Yes. Do it here:
    Apple - iPod touch – Feedback

Maybe you are looking for

  • Authorization best practices in AS Java

    I have been assigned the responsibility to create an authorization structure on the java stack. We would like to create groups with corresponding roles for developers and system administrators. Are there any best practices out there regarding this su

  • Workflow Approval for AR Credit/Debit Memo

    Hi All, I am looking for document on setting up Approval workflow for AR Credit / Debit Memo. Can any one share me document on how to set up AME for AR credit / debit memo approval. Thanks & Looking forward to your reply. Please send the document to

  • Displaying default styles in an advanced style as theme based foi

    Hi, I have a problem to display the default style of an advanced style as theme based foi. According to the mapviewer log x feature were found to display but no one was rendered into the map. MapViewer with image layer works, MapBuilder, too. MapView

  • Depreciation posting Error in unplanned run

    Hi I am exectuting AFAB deprecation run for unplanned depreciation Test run in background process. if iam exectuing test run directly it is not showing any errors just it saying as "Test run completed successfully.  But if am executing the Test Run t

  • Default_where sql statement problem

    hello gurus I am using forms 6i , having a form with data blocks AREA and AREA1 , their data sources are from single table 'area' right side of the form shows the list of all area names (only one attribute in tabular form ) inserted before , on trigg