Junk characters like" � � "displayed in the jsp page please help.

Hi,
I am getting junk characters like � � displayed in the jsp page.
In the JSP page i used javascript "& nbsp" for appending spaces to a string "CCR" to get "CCR " .
Now the Resultant string "CCR " has three spaces appended to its right.
This String is set in session in that JSP page.
In the next JSP page i am getting that string from session.
After getting the string the "substring" function is performed to get only the first 5 charcters of the string. Now the result is displayed as " CCR� � " with has last 2 characters as junk values � � insteed of displaying as "CCR ". Please help me in solving this issue.
Please note that initially the sting "CCR" is got from the Oracle database in Solaris Machine.
Regards,
Vijay

have you tried:
strenuously inspecting the string that is coming from the db? do an actual loop over the string, character by character, dumping to System.out to make sure the characters are EXACT coming out of the db.
note you have to append " " not just "& nbsp"
post the code that is doing the output. the relevant bean code, the jsp, everything relevant - WITH COMMENTS discussing where things are happening.
Also, is it "weird characters" in the browser only? have you done a view source on the actual html source that the browser is rendering (right click in IE and click view source). browsers can act odd if you don't feed then exactly what they want, and it looks like you're feeding it escaped characters that it is rendering as something else.

Similar Messages

  • Problem in Retrieve Image from DB and display in the JSP page

    Hi All,
    I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
    Database Used : MS Access
    DSN Name : image
    Table Name: image
    Image Format: bmp
    Output : 1973956
    Sample Program:_
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*" %>
    <%
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection conn = DriverManager.getConnection("jdbc:odbc:image");
              Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery("SELECT images FROM image");
              String imgLen="";
              if(rs.next()){
                   imgLen = rs.getString(1);
                   out.println(imgLen.length());
              if(rs.next()){
                   int len = imgLen.length();
                   byte [] rb = new byte[len];
                   InputStream readImg = rs.getBinaryStream(1);
                   int index=readImg.read(rb, 0, len);
                   System.out.println("index"+index);
                   st.close();
                   response.reset();
                   response.setContentType("image/jpg");
                   response.getOutputStream().write(rb,0,len);
                   response.getOutputStream().flush();
         }catch(Exception ee){
              out.println(ee);
    %>
    Thanks,
    Senthilkumar S

    vishruta wrote:
    <%
    %>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
                   out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
                   byte [] rb = new byte[len];Memory hogging. Don't do that.
              out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
    You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • Hi I am new to Apple devices, i got a new Ipad mini and i am trying to download skype from the Istore,it asks me to review my account and if i give all the details and click on next, it come to the same page,please help

    Hi I am new to Apple devices, i got a new Ipad mini and i am trying to download skype from the Istore,it asks me to review my account and if i give all the details and click on next, it come to the same page,please help

    Oh thank you very much, i was worried after a whole day's hard work but most important that i had lost my photos, i don't understan the photo,shared and albums? I have a lot of photos in my albums that it didn't let me delete, yet i could delete a lot of others, could you explain this to me please

  • I use printopia to print from my iPad, trying to print out a 4 page credit card statement, but it only prints out the first page, please help

    I use printopia to print from my iPad, trying to print out a 4 page credit card statement, but it only prints out the first page, please help

    What version of iOS are you using?  Some people were having this problem before, and it was fixed when they updated to iOS 5.

  • TS1372 my ipod classic is in disk mode, can,t get out of it, it says error 1439, what can i do, i tried everything, they said in the apple page, please help me.

    dear, Friends,
                         I have ipod classic, My ipod is in the disk mode, can't get out of it, it says error 1439, i had tried too many times, with trying to reset the ipod or restore it, but failed, please help me in this what can i do.

    Try going to settings and reset all settings. This worked for me.

  • Aceesing a particular jsp as the default page - Please help ASAP

    Hi,
              I want to access a particular jsp of mine as the default jsp.
              Say my jsp is located relative to the default web app root in this
              manner
              /security/jsp/mainMenu.jsp
              and currently I have to do -
              http://localhost:7001/security/jsp/mainMenu.jsp
              I want to be able to acces it either by
              http://localhost:7001/mainMenu.jsp
              or by
              http://localhost:7001/index.html
              or simply typing
              http://localhost:7001/
              as the url.
              What do I need to do in the web.xml file to be able to do this. If
              somebody could please let me know.
              Thanks,
              Sandeep
              

    ATIF_IQBAL wrote:
    Please suggest ASAP!!!
    Please don't flag your question as urgent, even if it is for you. Claiming urgency is very likely to be counter-productive: most forum regulars will simply ignore such messages as rude and selfish attempts to elicit immediate and special attention.
    Besides, unless a pack of rabid ninja spider monkeys is about to chase you over the edge of a cliff if you don't get an answer in fifteen seconds, your problem probably isn't as urgent as you think. :)
    * Post a subject line that describes the problem: Experts in your subject may skim right past subject lines like "Urgent" and "Need help ASAP". Use keywords about the technologies instead.
    -- From the [Java Forums FAQ|http://developers.sun.com/resources/forumsFAQ.html#Getting]

  • Display 20 records per page -- Pls help

    I am using sql query which returns some 1000 records, i have to display 20 records per page. I am using an enterprise bean that has finder method which returns arraylist of records. From this arraylist i am displaying in the JSP page. If after selection, if other user updates in the database, This won't reflect in the jsp page. How should i go about?

    oops,
    Implementing a Data Cache using Readers And Writers
    By Billy Newport, EJB Consultant
    http://www.theserverside.com/resources/article.jsp?l=Readers-Writers
    You may have come across a situation where you need to cache some data in your server. You then use this cache to service queries from incoming requests. You will also probably have a thread that listens for cache update events. This thread updates the cache in response to these events.
    This leads to a problem as it's unlikely that both the threads servicing requests and the update thread will be able to use your cache simultaeneously. You may be tempted to use an exclusive lock such as a Java synchronised block to handle this. This will work but it is probably the worst way that you can do this from a performance perspective. This articles shows how you can use reader writer locks to accomplish the same thing using a much more efficient technique.
    Reader writer locks.
    How to detect changes to the database?
    We can place triggers on a table. These triggers can call a stored procedure when-ever a record is updated/inserted or deleted. If we are caching the data in our application server then obviously when this happens we will want to know about it. We can split databases in to two categories when we look at implementing this. Oracle and everybody else.
    Oracle 8i
    Oracle is the most elegant. I'm assuming you're using Oracle 8i. Oracle 8i has a builtin JMS mechanism. We can define a queue in Oracle. Our pl/sql (or Java) stored procedure gets attached to the trigger. The stored procedure enqueues a message on the Oracle queue. The message would describe the event that happened. Our application servers will run a thread inside the application server VM that subscribe to and then listen to this queue. When a legacy system or an application server modifies the database then our triggers will call this stored procedure. It then enqueues the message. If the transaction is commited then the message is commited and sent to the listeners. If the transaction is rolled back then it is not commited and not sent. If the transaction is commited then all our application servers will receive the message. They can then use the message contents to see what happened and update the cache accordingly.
    Oracle 8 includes a full JVM. You could as an alternative use a Java stored procedure to multicast the event or send the event any way you choose. This isn't possible using Sybase or DB2 as they don't include the java.net package in the VM inside the database.
    If you're using an older version of Oracle then there is a way to send messages over an Oracle connection from the server to a client. Check your OCI manual for details. This message will be sent though regardless of the transaction outcome unlike the Oracle AQ solution.

  • Help needed urgently to get the values from the jsp page.

    hi,
    I am badly stuck into this problem.Please help me and find a solution.
    I am using ms-access and jsp.
    my database structure is as given below:
    m_emp_no | from_date | to_date | approver| status |
    1002 | 22/9/2008 | 23/9/2008|1003 |pending
    1004 | 29/9/2008 | 30/9/2008|1003 |pending
    2044 | 15/9/2008 | 16/9/2008|3076 |pending
    now this is exactly a leave apply scenario where a page is displayed and the user has to fill in the details to apply leave.then the approver has to approve that leaves so even, he should get the details in his account.
    for example here 1003 has to approve leaves for 1002 & 1004.i am able to fetch data from database for the particular approver here is the coding:
    <html>
    <body>
    <h2 align="center"><u><b><span style="background-color: #FFFFFF"><font color="#C0C0C0" face="Comic Sans MS">Leave
    Approval Requests</font></span></b></u></h2>
    <form method="POST" name="f1" action="update.jsp">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:employee_details");
    PreparedStatement p=null;
    p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
    ResultSet r=p.executeQuery();
    while(r.next())
    %>  <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
        <tr>
          <td width="100%" bgcolor="#999966"><b><u><%=r.getString(2)%></u></b></td>
        </tr>
      </table>
      <table border="1" width="100%" height="171" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
        <tr>
          <td width="100%" height="165" valign="top">
            <p align="left"><b>User ID</b>        :
    <input type="text" name="id" value="<%=r.getString(1)%>"  size="4   
         <b>status</b>:<%=r.getString(5)%</p>
    <p><b>Leave From</b> : <%=r.getString(2)%></p>
    <p><b>Leave From</b> : <%=r.getString(3)%></p>
    <p><b>Approve</b> : <select  size="1" name="approved">
            <option value="Approved">Approved</option>
            <option value="Cancelled">Cancelled</option>        </select></p>
    <%
    con.close();
    %>
      <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
              <tr>
                <td width="100%" bgcolor="#999966">
                  <p align="center"><input type="reset" value="Clear" name="B1"> 
                  <input type="submit" value="Submit" name="B2"></td>
              </tr>
            </table>
            </td>
        </tr>
      </table>
    </form>
    </body>
    </html>{code}
    this will display both the rows but when i try to retrieve the values into update.jsp using the code given below it gives me only one value which is the first 1002.
    {code}approved=(String)request.getParameter("approved");
    id=(String)request.getParameter("id");{code}
    but i need both the values to be inserted into the update.jsp only then the approver will be able to approve the leaves individually with respect to the m_emp_no.
    please help me out.
    thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    My comments below are all between (((((( and ))))))
    <html>
    <body>
    <h2 align="center"><u><b><span style="background-color: #FFFFFF"><font color="#C0C0C0" face="Comic Sans MS">Leave
    Approval Requests</font></span></b></u></h2>
    <form method="POST" name="f1" action="update.jsp">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:employee_details");
    PreparedStatement p=null;
    p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
    ResultSet r=p.executeQuery();
    while(r.next())
    %> <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" bgcolor="#999966"><b><u><%=r.getString(2)%></u></b></td>
    </tr>
    </table>
    <table border="1" width="100%" height="171" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" height="165" valign="top">
    <p align="left"><b>User ID</b> :
    <input type="text" name="id" value="<%=r.getString(1)%>" size="4   
    ((((((( in the statement above, name="id" should be changed to something like name="id"<%=ii%>
    Where ii is a counter that tells you how many times you have gone through the loop so far.
    The reason for this is that each textfield you generate must have a unique name rather than all have the same name
    such as 'id'. This change will give them names such as id0, id1, id2. Then when you submit the page, you can uniquely
    identify each input textfield.))))))
    <b>status</b>:<%=r.getString(5)%</p>
    <p><b>Leave From</b> : <%=r.getString(2)%></p>
    <p><b>Leave From</b> : <%=r.getString(3)%></p>
    <p><b>Approve</b> : <select size="1" name="approved">
    (((( the above select also has to have a unique name for each time through the loop. Change it to name="approved"<%=ii%>
    <option value="Approved">Approved</option>
    <option value="Cancelled">Cancelled</option> </select></p>
    <%
    con.close();
    %>
    <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" bgcolor="#999966">
    <p align="center"><input type="reset" value="Clear" name="B1">
    <input type="submit" value="Submit" name="B2"></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    (((((((note you would be better off long term to put your business logic in a servlet and dispatch to the JSP page which will only have the responsiblity to display the data.
    Also, connection pooling is better than the above.

  • Displaying content in JSP page, want BR but not other Html tags

    I have a page and am reading files and displaying the contents of the files onto the page in a <div> Oneissue is that in the file the end of line are \n or \r\n whichever operation system. I replaced those with <BR> no problem. Now my issue is that I display that in the JSP page:
    <c:out value="${filecontents}" escapeXml="false" />I use escapeXml so that <BR> will add the line breaks. Now my issue is that the file might contains other HTML tags that I want to display simply as text - I don't want the browser to render the other HTML tags.
    Is there a way to do that? Would I have to replace HTML tags with something special?

    Hmm... your file contains HTML tags, but you don't want the browser to interpret them as HTML tags, right? So the way to do that is to use escapeXml="true" in your c:out element.
    But then that also escapes the <BR> tags that you carefully put in there. And you don't want that. You want the browser to interpret those as HTML tags.
    I guess you can't have it both ways. Can you do something like outputting one line of the file at a time with <c:out ... escapeXml="true"> followed by <br>?

  • How to call an exe program from the JSP page?

    How to call and display the interface from a exe (residing on C: drive) on my JSP page. Our customers supplied us with an exe file and they want this to be incorporated on the JSP page that has other components also, like forms, etc. The interface of the program has to be displayed in specific co-ordinates on the JSP page. Any help is highly appreciated. Thanks in advance.

    Can't be done with JSP.
    JSP runs java on the SERVER only.
    All that gets to client is an HTML page. So all that
    you can do at the client is what an HTML page can do.
    Obviously that doesn't include running a file on the
    client machine.
    Take a look into Applets, or maybe ActiveX controls.Thanks for the reply.
    Any idea on how to use the ActiveX controls in this regard?

  • Help!!! Display "null" in JSP page

    Hi,
    I use the code like <%=adress%> in jsp.
    When the adress is null, the jsp page in S1AS will show a string "null". But the same code is OK in weblogic ,the jsp will show empty for this part of code
    What is difference between them ?If I do not want to change the code (many places) ,is there any way to confirgue sun one or easy ways to solve this problem?
    Could evry expert to help me to firgure out how to solve this problem?
    Thanks in advance,
    FS

    You also might want to check JDK versions and J2EE versions being used. These might yield different results.

  • Determine the outcome of an action in the jsp page?

    can i determine the outcome of an action in the jsp page?
    for example:
    i create a jsp file that contains two links, that play the role of tabs....
    the action is different for the two links say "action1" and "action2" but the result page is the same original page...
    can i determine what whas the action the user clicked?( so that i can display different things, according to action )

    you can use the <f:param> component with your commandLink and set a different value for each of your link. Then, in your jsp, you should be able to retrieve the value of the parameter in the request.

  • Display image on jsp page

    I have to display image on jsp page with some text output. This image is already saved at a location parallel to web-inf and is generated dynamically using a servlet. I have used img tag html to display the image. Other outputs are taking their values from database.
    First problem is that image will be taking time to display in comparision of other outouts from database. I have to refresh the page to get imageon my page.
    Second is that if I save image in a folder parallel to web-inf in my project then it will not be displaying the image.
    Can I use any jsp functionality to display image with other outputs from database. I have used "*include*". but it shows only that image and other outputs.

    Best way is to use a servlet for this.
    <img src="path/to/imageservlet?id=someidentifier">
    <!-- or -->
    <img src="path/to/imageservlet/someidentifier">In the servlet's doGet() just write code which gets an InputStream of the image (either directly generated, or just read from the local disk file system, if necessary with help of ServletContext#getRealPath(), or even from the DB by ResultSet#getBinaryStream()) and writes it to the OutputStream of the response. That's basically all. Don't forget to buffer the streams properly to speedup performance and to save memory.
    You can find here a basic example: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • JSP and servlets(displaying Data On JSP page)

    Hiii all
    i am new to JSP ...also to servets
    tell me hw to print my data on the JSP page,
    i can print my data on the server,that data i want to print on JSP page
    if u all have e.g's it will be very good
    Thanks in advance
    Take Care
    Rahul :)

    What do you mean "print data on a JSP?" If you simply mean display dynamic content, you should def read up both on sun's resources and other googled resources for JSP walkthroughs...

  • Post messages on the jsp page

    This is my jsf(jsp) page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <f:view>
    <h1 align="center">File Selection Page</h1>
    <h:panelGroup>
    <form id="uploadForm" method="post" action="Multipart.do" enctype="multipart/form-data">
        Specify your name:<br />
        <input type="text" name="name"><br /><br />
        Specify your files: <br />
        <input type="file" name="file1"><br /><br />
         <input type="file" name="file2"><br /><br />
         <input type="file" name="file3"><br /><br />
        <input type="file" name="file4"><br /><br />
    <br><br>
    <center>
    <input type="submit" name="Submit" value="Submit Your Files">
    </center>
    </form>
    </f:view>
    </body>
    </html>I am using apache commons multipart file upload. How do I post success or failure messages to this page?
    As you see I am using a servlet(not shown - which uses Faces Context to populate the messages). Not sure how to get these out in the jsp page.
    Thanks,
    Sonia
    Edited by: sun_sonia on Nov 23, 2009 2:42 PM

    You're using plain HTML <input type="file"> elements. Use Tomahawk's <t:inputFileUpload> components instead of you want to make use of JSF's validation and messaging capabilities.
    If you insist in using a servlet instead of a bean for this, then just do all the usual JSP/Servlet way. My suggestion would be to hold a Map<String, String> which contains the fieldname-message pairs which you store in the request scope and then use the usual JSP/EL way to display them.

Maybe you are looking for

  • How to send mails through Alerts.

    Hi All, I have an requirement to send email to different user periodically after checking some condition in HRMS application.Initially I was trying with the help of JAVA Api.Now while R & D I found that I can do it by using Oracle Alerts.but I dont k

  • Opening a new tab from link without moving to the new tab

    Hi, first of all thanks to the firefox team for such a innovative product, without this browser my day is incomplete. I have a query, when we use Alt+Ctrl+T to open a link in a new tab the focus also moves to the target new tab. Is there any shortcut

  • Location of class storage on Sun one

    Hi all, I am not a java programmer and I am supposed to post a questionnaire using jps files and Java classes. The original code were delevoppped for appache and I would like to put them on a website using Sun One server. The java classes were stored

  • No keyboard, but Mac still goes into clamshell mode

    How do I prevent this? I have power attached and an external monitor. No keyboard, no mouse, no bluetooth devices, no USB devices. When I close the laptop lid it moves all my apps to the external monitor and stays on. I want it to sleep. The Apple do

  • Cluster Application Server 10g (with SSL)

    I need to know if I should consider a digital certificate each application server that conform the cluster?