How do I Display a string from a servlet into a JSP Page???? NEED HELP!!!!

Hi guys,
How do I Display a string from a servlet into a JSP Page...
Ive tried so many bloody things!.....
Simply.
I get text from JSP. The servlet does what ever it does to the string.
Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
please help!!!

hmmm, I dont really like using JSP programming, u should be using JAVA..
the way to do it is:
Call and cast to the bean like this:
<%@ page import="beans.*" %>
<% //cast to bean get request create object
userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
then... all you do is call it like this:
<input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
this is the real programmers way,,,
chet.~

Similar Messages

  • Display multiple Images from a DB on a JSP Page!

    Hi all, please give me your solution, thanks. I have many images, stored in Oracle database (BLOB), How to display all of them (images) on a JSP page? I have a working solution that only shows one image based on the specific image-name passed. But if no image found in the Database with that image-name then I want to show all the images at once on a JSP page. Can someone help please. Follwing are the code snippets:
    Here is the JSP page that calls the servlet to show the images:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>untitled</title>
      </head>
      <body valign=center>
          <table>
            <tr>
                <td>
                    <img src="/test-testimgs-context-root/servlet/test1.images.servlet.GetImage">
                </td>
            </tr>
          </table>
      </body>
    </html>
    Here is the code that resides in the service method of GetImage servlet:
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
        OutputStream stream = response.getOutputStream(); 
        Blob imgBlob = null;
        ResultSet rs = null;
        byte[] imbBytesAry = null;
        try
            ImageTest imgtest = new ImageTest();
            rs = imgtest.get("img1.tif");
            if(rs != null)
                while(rs.next())
                    imgBlob = rs.getBlob(1);
                    int len = new Integer( new Long( imgBlob.length()).toString() ).intValue();
                    imbBytesAry = imgBlob.getBytes(1,len);
                    if (imbBytesAry.length == 0 || imbBytesAry == null)
                        noImageFound(request, response); 
                    else
                        stream.write(imbBytesAry);
            else
                noImageFound(request, response);
        catch (Exception e)
            noImageFound(request, response);
    Here is the code that resides in the get method of ImageTest class:
    public ResultSet get(String fileName) throws DatabaseConnectionException, SQLException, Exception
    Connection connection=null;
    ResultSet rs = null;
    ResultSet rs1 = null;
    Blob imgBlob = null;
    try
        connection = new ConnectionProvider().getCConnection() ;
        connection.setAutoCommit(false);
        Statement stmt = connection.createStatement();
        String sql = "SELECT IMG FROM IMAGE_TABLE WHERE IMAGE_NAME = ? "; 
        PreparedStatement pstmt = connection.prepareStatement(sql);
        pstmt.setString(1,fileName);
        rs = pstmt.executeQuery();
        boolean flag = rs.next();
        if(flag)
            rs.beforeFirst();
        else
            sql = "SELECT IMG FROM IMAGE_TABLE"; 
            rs1 = stmt.executeQuery(sql);
            boolean flag_all = rs1.next();
            if(flag_all)
                rs1.beforeFirst();
            else
                rs1 = null;
        return rs;
    }As you see in the JSP page I am calling GetImage servlet, whose service method does all the processing i.e. calls ImageTest get method that queries the database and returns the result. Eventually what I would like is to pass the filename along with other parameters from JSP page and the servlet returns the images based on that. Currently I have just hard coded a value for testing puposes. Any help is appreciated.
    Thanks

    Hi all, please give me your solution, thanks. I have many images, stored in Oracle database (BLOB), How to display all of them (images) on a JSP page? I have a working solution that only shows one image based on the specific image-name passed. But if no image found in the Database with that image-name then I want to show all the images at once on a JSP page. Can someone help please.
    this is the code
    <form name="a" action="" method="post">
    <%
    rs1 = st1.executeQuery(select1);
    rs1.next();
    while(rs1.next())
    %>
    <table>
    <tr><td>
    <%
    Blob objBlob[] = new Blob[rs1.getMetaData().getColumnCount()];
         for (int i = 0; i <= rs1.getMetaData().getColumnCount(); i++)
               objBlob[i] = ((OracleResultSet)rs1).getBLOB(1);
              InputStream is = objBlob.getBinaryStream();
    byte[] bytearray = new byte[4096];
    int size=0;
    response.reset();
    response.setContentType("image/jpeg");
    response.addHeader("Content-Disposition","filename=getimage.jpeg");
    while((size=is.read(bytearray))!= -1 )
    response.getOutputStream().write(bytearray,0,size);
    response.flushBuffer();
    is.close();
    out.println("hhhhhhh");
    %>
    </table>
    <%
    rs1.close();
    //con.close();
    %>
    </form>

  • How can a user scroll the resultset obtained from a servlet in a jsp page?

    Actually i am having a page where user has to select company name and for tht i am providing him with a button, and on clicking tht button a
    new search page is provided , and on mentioning the search criteria ,a servlet is fired which returns a list of companies(tbasically i am creating a session object of resultset type which stores the companies name), now the servlets again goes back to search page, and here i want 2 display the company names, i am able to display company names in my search page , but now i want my user to select one of the companies from tht servlet.
    for tht i need to tap the onMouseOver function of java SCript, C
    Can any one tell me how to write code for tht
    Thanking in Advance

    see https://addons.mozilla.org/en-US/thunderbird/addon/send-later-3/

  • Extracting a value from the j_security_check servlet into a JSP page

    Hi Folks...
    I have a problem as follows:
    I log in into the web app, via my login.jsp page. Below is the code for the form that accepts the login information
    <form method="POST" action="j_security_check">  
    <table cellpadding="0" cellspacing="0" border="0">  
      <tr>  
        <td align="right">Username: </td>  
        <td><input type="text" name="j_username"></td>  
      </tr>  
      <tr>  
        <td align="right">Password: </td>  
        <td><input type="password" name="j_password"></td>  
      </tr>  
      <tr>  
        <td></td>  
        <td><input type="submit" value="Login"></td>  
      </tr>  
    </table>  
    </form>Login is sucessful and I am brought to the 'studentstub.jsp' page. I would like the user name to appear on the 'studentstub.jsp' page. I used the following code in the 'studentstub.jsp' page :
    <td><%= request.getParameter("j_username")%></td>  but all I am getting is a null. The 'j_security_check' servlet is not exactly part of my package, but the glassfish app server. Is there anything wrong in the way I am extracting the information from 'j_security_check' ? Hope someone can advise, thanks.

    Hi Folks..
    I managed to get a reply from another forum and the suggested solution works. I am going to share it with everyone here.
    I repalced this line of code:
    <td><%= request.getParameter("j_username")%></td>with this:
    <td><%= request.getRemoteUser()%></td>The 'getRemoteUser' method from HttpServletRequest returns the name of the authenticated user. I hope this information will be helpful to those caught in a simillar problem. Thanks.

  • Retrieving lists from other layer into a JSP page - Design Question

    Hi all,
    What should be a good design technique in order to allow a JSP page to present some list obtained from other layer of my application. I intend to leave only presentation logic in the JSP layer, while all data access will be in other layer.
    For example, I have a JSP page that will show the results of a SQL query originated from an entry form in other JSP page. Let's name them 'search.jsp' and 'result.jsp'
    I want that all JDBC access be done in some other layer.
    Question 1:
    What would be better for this task? A servlet or a bean? (A bean, I suppose?)
    Then this bean (?) would have to find some way to pass all the result set into this 'result.jsp'. I think it would be very poor design if I used some Data Object, because it would have to store all rows and pass them at once.
    I don't want, either, that the presentation (JSP) layer access directly the data access layer (JDBC, files...). This way, I don't want any JSP page accessing the Resultset object directly.
    Question 2:
    What do you think could be a good design technique?
    I thought of some intermediate layer that provided data objects and data access interfaces. I mean, as my data will come from different sources, like some database (JDBC), some Electronic Document Manager, I thought of having a common access interface, that would provide methods for accessing the resultsets. This could be even a java.util.Enumeration that has a hasMoreElements() method that could be implemented as the next() method from JDBC result sets and the nextElement() method that would actually bring the next row of data.
    This way the JSP layer would see only hasMoreElements() and nextElement() methods from the middle layer. On the other hand, the data layer would provide as many different implementations to this access interface (Enumeration?) as there were data sources (JDBC, Files, ...)
    Question 3:
    What do you think of this design?
    Question 4:
    Is there any flaw in my approach? Which?
    Question 5:
    Could you suggest other designs?
    I really thank you all, for any kind of answer. I actually use this design for development, however I've never seriously discussed it with someone... this is going to be of great value for me.
    Regards,
    Filipe Fedalto

    Well I saw you question and I'll tell you what I do.
    I have JSP's which post form data to servlets.
    The servlet then calls a factory to produce a ResultContainer (analagous to your lists) which is generated
    via JDBC, and/or request parameters etc...
    this provides a single point of reference and a "group" of containers (functions really) that can be produced and reused (same container different amount of data)
    I also have other static classes which can manipulate the data in the containers
    (such as add additional info to the items in the containers) before I forward the container (request attribute)
    to the JSP page
    Additionally I use Type safe constants for all my HTML form tag names (easier to change and ensure the same name is used everywhere when reading parameters) and again for item statuses
    and any other info I need to send along with the page (using Javascript to update the
    status to another type safe constant).
    I've found that using factories for ResultContainers is very worthwhile and allows you to implement additional servlets extremely quickly (mostly reusing containers that exist) and since the
    container is the same for all my JSPs (this may not be the case with you) I can implement JSP's
    very quickly as well (just change the view)
    btw I refrain from calling my ResultContainer a bean because it is not serializable
    I don't know if this will help but at least it gives me a forum to test my ideas
    Thanks

  • Sendredirect() from a servlet to a jsp page

    Hi all,
    From word document, I have some links like this: http://localhost:8080/Test/GetFileServlet?Name=Peter&Age=12
    when I click on the link, the GetFileServlet will check for user authentication.
    If i haven't logged in yet, servlet will kick me to Login.jsp (jsf) to login. I use a servlet filter to filter users.
    Once logged in, the page backing bean of login.jsp (Login.java) will send me to output.jsp which is only accessable to authenitcated users.
    That works great......
    Here is the problem when I click on the same link again.. With that I'm expecting the Servlet to kick me straight to output.jsp of JSF
    However, it keeps kicking me back to the login.jsp instead of output.jsp...
    Here is my sendredirect code in servlet
    resp.sendRedirect("http://10.80.54.240:8080/Test/faces/Local/output.jsp?Name=Peter&Age=12);

    iT'S OK..i fixed it using dispatcher

  • How include a Servlet into a JSP page?

    Hi!!
    I need make a combobox with a servlet and place its result into a jsp page.
    The servlet is in a package, but when i do: <jsp:include file="sic.view.servlet.ComboServlet" />
    tell me that "file attribute isn�t a valid attribute name"
    whow can i do to make the combobox whit the servlet and include this into the jsp page??
    Thanks!!
    PD: Sorry my pour English...

    Servlets should be mapped to a URL, then you access the servlet via that URL.
    The servlet mapping is done in the web.xml (in WEB-INF/ directory of your web application)
      <servlet>
        <servlet-name>
          Combo_S
        </servlet-name>
        <servlet-class>
          sic.view.servlet.ComboServlet
        </servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>
          Combo_S
        </servlet-name>
        <url-pattern>
          /combo
        </url-pattern>
      </servlet-mapping>Then you would use:
    <jsp:include file="combo" />
    to include it.
    Make sure the class file gets put in the right package under WEB-INF/classes/

  • How to display outsream from a servlet in a JSP

    I wrote a jsp file to call a Servlet, then want to display the result from the servlet in another jsp file. Anyone can give me possible solution or an example to illustrate it.
    Many thanks in advance.
    the file that call servlet in a jsp is as follow
    <form method="POST" action="myservlet">
    <table>
    <tr>
    <th align="center" colspan="2">
    Enter The query words
    </th>
    </tr>
    <tr>
    <th align="right">query words:</th>
    <td align="left">
    <input type="text" name="querywords" size="60">
    </td>
    </tr>
    <tr>
    <td align="right">
    <input type="submit" value="Search">
    </td>
    <td align="left">
    <input type="reset" value="Reset">
    </td>
    </tr>
    </table>
    </form>
    ............

    I would suggest that you use the Servlet to retrieve the data you are after and store it in the session. Then forward the user onto the JSP page where it can retrieve the object from the session and present it to the user in a formatted view.

  • Can a servlet make a jsp page display?

    A total newbie question. If I do this in a servlet:
    RequestDispatcher rd = request.getRequestDispatcher( "/index.jsp" );
    rd.forward( request, response );
    - does index.jsp in the context path actually display?
    If yes, what's wrong if it doesn't display?

    Yes, you can pass control from your servlet to the JSP page that way. If it isn't displaying, then you should show us the error message you are getting so that we can help you more effectively.

  • How to pass a string from a servlet to client side

    hi,
    i would like to generate a string from a servlet and pass it to the client side. the client will receive the string by using request.getParameter(). How should i implement this system? Could anybody give me some hint?
    Best Regards,
    Henry

    Greetings,
    hi,
    i would like to generate a string from a servlet and
    pass it to the client side. the client will receive
    the string by using request.getParameter(). HowAre you referring to the instance of (Http)ServletRequest the 'request' object being passed to the "client"? What is the "client" in this case? If you mean a "traditional" client communicating over (or by tunneling through...) HTTP then no can do. The (Http)ServletRequest object is generated by the web container (a.k.a. "servlet engine"), not by the client, and it is not serializable so there is no way to pass it back to the client...
    should i implement this system? Could anybody give me
    some hint?It depends again on "what is the 'client' in this case?"
    Best Regards,
    HenryRegards,
    Tony "Vee Schade" Cook

  • How can i display at  JTextArea from right to left

    how can i display at JTextArea from right to left?
    i try to write setAlignmentX(JTextArea.RIGHT_ALIGNMENT)
    but this not help,
    thanks for help.

    use this
    JTextArea.applyComponentOrientation(java.awt.ComponentOrientation.RIGHT_TO_LEFT);

  • How to get calendars and notes from my iPhone into iCloud?

    Hello all,
    yesterday I got a new MacBook Pro Retina at work. This upgrade me to OSX 10.8 from 10.6, so I planned to use iCloud to sync my iPhone 5 and my Mac this way. So far I synced the devices manually via iTunes.
    However, so far I only got Contacts to sync with iCloud correctly. Calendars and notes just don't do it, although their sync is turned on on the iPhone as well as on the Mac.
    All my attempts to get it to work obviously destroyed the possibility to sync calendars via iTunes - after a sync there is just nothing showing up in Calendar. This is really bad as now I can only access my calendars via the iPhone.
    Since my iPhone now contains the most recent calendar and note data the question is even more simple: how can I get these data from my iPhone into iClous so they will also sync with my Mac (and from then on on all devices)?
    It doesn't work by just turning calendar sync on on the iPhone. When I do this, I now see two calendar groups "From my Mac" and "From iCloud". Great, but what I want is to replace "From iCloud" with "From my Mac".
    I have already reset iCloud, but this didn't help either.
    I'm close to desperation, so any hints are very much appreciated!
    Thanks and best wishes,
    Thomas.

    Solved - it was a general sync problem. Today I was not even able anymore to sync my calendars via iTunes. Problem and solution see https://discussions.apple.com/thread/5505069.
    Best,
    Thomas.

  • I got a new computer and some of my music apparently wasn't backed up to the external hard drive.  I have some of the music that didn't save on an iphone. How do I move the music from the iPhone into my iTunes library on the computer?

    I got a new computer and somehow have lost some of my more recently purchased and or imported music.  I have some of that music on an iphone and some on an ipad.  How do I get the music from those devices into my itunes library without losing everything else?

    Some of the information below has subsequently appeared in a document by turingtest2: Recovering your iTunes library from your iPod or iOS device - https://discussions.apple.com/docs/DOC-3991
    Your i-device was not designed for unique storage of your media. It is not a backup device and media transfer was planned with you maintaining a master copy of your media on a computer which is itself properly backed up against loss. Syncing is one way, computer to device, updating the device content to the content on the computer, not updating or restoring content on a computer. The exception is iTunes Store purchases which can be transferred to a computer.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer - http://support.apple.com/kb/HT1848 - only purchases from iTunes Store
    For transferring other items from an i-device to a computer you will have to use third party commercial software. Examples (check the web for others; this is not an exhaustive listing, nor do I have any idea if they are any good):
    - Expod (free) - http://www.headlightsoft.com/expod/ - Mac, universal for 104.+ (newer machines try de-Tune)
    - deTune (free) - http://www.headlightsoft.com/detune/ - Mac, 10.5+
    - Senuti - http://www.fadingred.com/senuti/
    - Phoneview - http://www.ecamm.com/mac/phoneview/
    - MusicRescue - http://www.kennettnet.co.uk/products/musicrescue/
    - Sharepod (free) - http://download.cnet.com/SharePod/3000-2141_4-10794489.html?tag=mncol;2 - Windows
    - Snowfox/iMedia - http://www.mac-videoconverter.com/imedia-transfer-mac.html - Mac & PC
    - iexplorer (free) - http://www.macroplant.com/iexplorer/ - Mac&PC
    - Yamipod (free) - http://www.yamipod.com/main/modules/downloads/ - PC, Linux, Mac [Still updated for use on newer devices? No edits to site since 2010.]
    - 2010 Post by Zevoneer: iPod media recovery options - https://discussions.apple.com/message/11624224 - this is an older post and many of the links are also for old posts, so bear this in mind when reading them.
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive - https://discussions.apple.com/docs/DOC-3141 - dates from 2008 and some outdated information now.
    Copying Content from your iPod to your Computer - The Definitive Guide - http://www.ilounge.com/index.php/articles/comments/copying-music-from-ipod-to-co mputer/ - Information about use in disk mode pertains only to older model iPods.
    Get Your Music Off of Your iPod - http://howto.wired.com/wiki/Get_Your_Music_Off_of_Your_iPod - I am not sure but this may only work with some models and not newer Touch, iPhone, or iPad.
    Additional information here https://discussions.apple.com/message/18324797

  • TS2755 Hi all, I bought one iphone and 3 ipads, i set up all on one apple ID. Now i have a problem when using messages: when sending message from one device it appears again on screen from the other 3 devices. I need help of how to set up messages on each

    Hi all, I bought one iphone and 3 ipads, i set up all on one apple ID. Now i have a problem when using messages: when sending message from one device it appears again on screen from the other 3 devices. I need help on how to set up messages on each device separately and to start using messages app on each device independently. Thanks

    search google for "iphone remove picture from contact"

  • HT1449 how do you move all music from two computers into one itunes account?

    How do you move all music from two computers into one itunes account?

    An "iTunes account" is an online account you use for buying music, like a bank account.  An iTunes collection is the media you see when you open iTunes. Which do you mean?
    If it is two computers, it would also help to know where these are located. Are they on the same local network? If they are, try Home Sharing (and you have control of both and you aren't just trying to get music fro your computer to your friend's computer in another state).  If they are not, you'll have to use an external hard drive or flash drive.
    Is this on a PC? Your computer information says Windows but you posted this in the iTunes for Mac forum.

Maybe you are looking for