Word/JSP

Hi,
I need to display a recordset in a word document as it appears on a web
page.
Changing the content type doesn't work, because when saved, all the html
tags are also copied into the word document.
example:
1,John Smith
2,Jane Doe
etc
Can anybody explain how this can be done?
Thanks
Vito

Instead of trying to use word document.
Try using a rtf document.
RTF is the basics of a word document. You can find more
about this on microsoft.com website.
You write your result from your recordset to the rtf document in
a specific format.
Afterwards open a link to the rtf document.

Similar Messages

  • Open word document in jsp

    I have a jsp file and i open a new page(word document) with a link in this jsp page. Text messages are viewed correctly in WS-Word but there is a problem for images...
    1 _ How can i solve this problem?
    2 _ After opening word document, if opened word document is saved to anywhere of computer, how can i know address location of it in jsp?
    First File (a part of code):
    <a style="cursor: hand;"
    onClick="window.open('.../word.jsp','','height=400,width=600,scrollbars=yes,resizable=yes')">
    test link14 - open word file
    </a>
    Second File : (word.jsp) All of the code...
    <%@ page contentType="text/html;charset=windows-1254"%>
    <%
         response.setContentType("application/msword");
         response.setHeader("Content-disposition","attachment;filename=firat_WordDoc.doc");
    %>
    <%@ page language = "java" %>
    <html>
         <head></head>
         <body>
              <img src="car.jpg" width="100" height="100" border="0" alt="car"/>
              <br>
              test text...
         </body>
    </html>
    In second jsp file (word.jsp), "test text..." are written coorectly to word document named firat_WordDoc.doc but car.jpg is not viewed

    You wont be able to see it as becoz all you are doing is asking teh browser to paint a JSP [HTML] Page and asking it to open in the format msword.
    Save the word document and open it in textpad or notepad, you will see that the HTML is embedded within the Word Document rather than binary data. And you can see that the Image will aso be a IMG tag with refeence to the car.jpg.
    In order for you to do this either consider
    1. Using full URL in the Image tag.
    2. Using COM Bridge [JIntegra] License Software to build a new Word Document at runtime and then paint it.
    3. I think POI is free ware to do this.

  • Applets embedded in JSP

    Hi,
    Another newbie question here sorry.
    I have the following directory structure in my web app:
    root_dir
    root_dir/JSP_dir1/JSP_sub_dir1/main.jsp
    root_dir/WEB-INF/lib
    main.jsp has an embedded apple - the markup looks like this:
    <applet
      code="com.somepackage.somesubpackage.Class"
      archive="../WEB-INF/lib/myjar1.jar,
            ../WEB-INF/lib/myjar2.jar,
         ../WEB-INF/lib/myjar3.jar,
         ../WEB-INF/lib/myjar4.jar,
         ../WEB-INF/lib/myjar5.jar"The problem is that when I access main.jsp the applet doesn't show up - instead there are errors and JavaConsole shows the following:
    load: class com.somepackage.somesubpackage.Class not found.The relevant JAR's are in the WEB-INF/lib folder. Given the directory structure I mentioned above is it possible that the class could not be found because I am pointing to the location incorrectly? If that is not the case could anyone please suggest what the issue might be?
    Thanks.

    Thanks, this is very helpful. I guess the other part of my question is, if my JSP's are in the following directory structure:
    App-Root/JSP/JSP_subfolder/main.jsp.
    And the AppletJars folder is:
    App-Root/AppletJars/And the applet is embedded in main.jsp, the libs I reference out of that JSP, does their dir path have to be preceded by../../ or only ../. In other words, JSP's that are located two directories down, do they have to look two directories up?
    It may sound like a stupid question, but it is not obvious to me that after the JSP gets compiled into a Servlet it keeps its directory tree. I also think I encountered a situation recently where even though the JSP was nested within 2 folders it had to look only one directory up for something. Am I wrong?

  • Jsp file not able to locate class file in JWS 2.0

    hello all,
    i am a beginner at jsp...
    my problem....
    i have created a jsp file which accesses a SpellCheck.class file..
    i am using Java Web Server 2.0...
    and in the classpath i have set the classpath variable to c:\javawebserver2.0\lib. I have placed the class file in this directory.
    Now when i run the jsp file it gives the following errors...
    C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_wordpro.java:73: Class pagecompile.jsp.SpellCheck not found in type declaration.
    SpellCheck help = null;
    ^
    C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_wordpro.java:76: Class pagecompile.jsp.SpellCheck not found in type declaration.
    help= (SpellCheck)
    ^
    C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_wordpro.java:81: Class pagecompile.jsp.SpellCheck not found in type declaration.
    help = (SpellCheck) Beans.instantiate(getClassLoader(), "SpellCheck");
    ^
    3 errors
    i guess this is happening because it cant find the .class file.
    MY QUESTION IS:
    where should i place the class file so the the .jsp is able to locate it??
    the code of the jsp is as follows:
    <%@ page language="java"%>
    <jsp:useBean id="help" scope="request" class="SpellCheck">
    <%
         System.out.println("Working with the bean");
         help.setWord(request.getParameter("word"));
    %>
    </jsp:useBean>
    <html>
    <body>
    You entered the input,
    <b> <%= request.getParameter("word")%></b><br>
    The processed output is:<br>
    <%= Integer.parseInt(request.getParameter("mode"))==1 ? help.reverse() : " "+help.check() %>
    </body>
    </html>

    just place your class file in JWS2.0/classes directory
    and restart you Serverhi
    yes ive done it...
    1. ive placed the .class file in JWS2.0/classes directory
    2. ive placed the .jsp file and the .html file in the JWS2.0/public_html directory... it still does'nt work...
    :o(
    boney

  • Passing values to javascript from database

    hi friends,
    I have to fetch values from the database and pass the values to the java script variable.
    I tried this, but is not working. When i place the script inside the java, it isnt working. Iam passing value to this script variable as argument to a function. This is my code:
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    while (rs.next())
    for (int i = 1; i <= numberOfColumns; i++)
    count=count+1;
    if (i > 1)
    columnValue = rs.getString(i);
    %>
    <script>
    var hcbList = [<%=request.getParameter("columnValue")%>];
    </script>     
    <%           
    System.out.println("");
    st.close();
    %>
    Pls solve the problem. Its very urgent!
    thanx

    Keep this in mind: JSP is source generation software.
    In other words JSP generates the HTML and/or Javascript that will be rendered on the browser. So What you need to do is keep the JSP and Javascript separate in your mental picture. You ask yourself, "what would the finished Javascript code look like that would give me the results?" Then you apply JSP as a template to fill in the blanks. In your example you want a list or an array of values in your Javascript. I don't use Javascript to often but from memory I belive an array in Javascript is something like this:
    <script>
    var hcbList = {"val1", "val2, "valx"};
    </script>That's what the finished Javascript would look like. Now you apply JSP as a template.
    <!-- This is the fill-in-the-blank template
    <script>
    var hcbList = {<%=insertArrayHere%>};
    </script>Now you fill in the blanks
    //insertArrayHere is your blank
    String insertArrayHere = "";
    //iterate over the collection and build a string that represents the JS array
    for(int i = 1; i <= numberOfColumns; i++)
       //wrap each value with quotes if it is to be a JS string
       insertArrayHere += "\"" + rs.getString(i) + "\"" + ","; //terminate with a comma
    //trim the last comma off the array guts
    insertArrayHere = insertArrayHere.substring(0, insertArrayHere.length() - 1); Now I'm sure that's not exactly what you want because it looks like you got some crazyness going on in your logic. I don't know how you can query the using values from the database. Anyhow it poses as a good example of how to apply the concept of the two technologies. (Also, why are you doing a System.out from JSP? You should be calling log() if you want console output.) The whole idea is that JSP can NOT talk directly to Javascript. It can only generate Javascript dynamically before it is received by the browser.

  • Error-page in web.xml: error page doesn't show

    Hi,
    I added the following block in web.xml file:
    <error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/ESU9098J.jsp</location>
    </error-page>
    When I force an exception, I get a pop-up for downloading a file named EAC0002Se04379bf (where EAC0002S is the name of the servlet in which the exception happens). Can anybody help?
    I use OC4J 10221 on Win Xp with JDK 1.3.1
    Thanks
    Jean

    This is due to a erroneous MIME type mapping in one of the OC4J config files.
    To resolve it:
    Modify mime.types under $OC4J_HOME/config by removing the line application/jsp (for some unknown reason, there are two of them in the file) or renaming the
    word jsp into some other name, ex.:
    "application/jsp jsptemp"
    for both the 2 lines. Then add "jsp" to the end of the "text/html" line, ex.:
    "text/html html htm jsp".
    This will make oc4j use text/html in the response when a jsp file is being processed that's why it's very important to eliminate application/jsp by renaming jsp or simply deleting the line.
    We fixed this error in the config file in a later release.
    cheers
    -steve-

  • Open/save word document in jsp

    I can open a word document in jsp but i don't know how to save and close it to where i want again inside same jsp.
    I find a code that do thing i want to do but it was written in vb script.
    How can i convert vb code below to java / jsp?
    Dim wrdApp As Word.Application
    MyStr = Format(dtMyDate, "mmm dd, yyyy") & ".doc"
    Set wrdApp = New Word.Application 'released first resources
    With wrdApp
    .Documents.Add "normal.dot", , , True
    strPatientName = txtName.Text
    strFileName = "c:\MJCC\Lab\" & strPatientName & "_" & MyStr
    .ActiveDocument.SaveAs strFileName
    .ActiveDocument.Close
    .Quit
    End With
    Set wrdDoc =Nothing

    <%@ page contentType="application/vnd.ms-excel" language="java"%>
    <meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=iso-8859-1">
    by using this 2 codes, when i run this page, it will pop up a box for me to save the jsp file..
    i'm able to save it in xls / csv format...
    so, mayb you can try change the ms-excel to ms-word or something else..
    hope this is useful...

  • Using JSP/Servlet to write Word Document to BLOB

    Hi
    I need some help pls
    When I use a normal class with a main method, it loads the word document into a blob and I can read this 100%.Stunning.
    With a JSP/Servlet I cannot get the document out again. The "format" seems to be lost.
    Any ideas,help greatly appreciated:
    Here is the Main class that works:
    package mypackage1;
    import java.io.OutputStream;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.FileNotFoundException;
    import java.io.Writer;
    import java.sql.Connection;
    import oracle.jdbc.*;
    import oracle.jdbc.OracleResultSet;
    import oracle.sql.BLOB;
    import org.apache.log4j.Logger;
    import Util_Connect.DataBase;
    public class TestLOB
    //static final Logger logger = Logger.getLogger("test");
    public TestLOB()
    public static void main(String args[])
    TestLOB testLOB = new TestLOB();
    testLOB.TestLOBInsert("c:\\my_data\\callcenterpilot.doc");
    public void TestLOBInsert(String fileName)
    Connection conn = getConnection("wizard");
    BLOB blob = null;
    try
    conn.setAutoCommit(false);
    String cmd = "SELECT * FROM so_cs.testlob WHERE docno = 1 FOR UPDATE";
    PreparedStatement pstmt = conn.prepareStatement(cmd);
    ResultSet rset = pstmt.executeQuery(cmd);
    rset.next();
    blob = ((OracleResultSet)rset).getBLOB(2);
    File binaryFile = new File(fileName);
    System.out.println("Document length = " + binaryFile.length());
    FileInputStream instream = new FileInputStream(binaryFile);
    OutputStream outstream = blob.getBinaryOutputStream();
    int size = blob.getBufferSize();
    byte[] buffer = new byte[size];
    int length = -1;
    while ((length = instream.read(buffer)) != -1)
    outstream.write(buffer, 0, length);
    instream.close();
    outstream.close();
    conn.commit();
    closeConnection(conn);
    catch (Exception ex)
    System.out.println("Error =- > "+ex.toString());
    private Connection getConnection(String dataBase)
    Connection conn = null;
    try
    DriverManager.registerDriver(new OracleDriver());
    conn = DriverManager.getConnection("jdbc:oracle:thin:@oraclu5:1600:dwz110","so_cs","so_cs");
    catch (Exception ex)
    System.out.println("Error getting conn"+ex.toString());
    return conn;
    private void closeConnection(Connection conn)
    if (conn != null)
    try
    conn.close();
    catch (Exception se)
    System.out.println("Error closing connection in get last imei"+se.toString());
    Works fine:
    Here is the display servlet: Works when main class inserts file
    package mypackage1;
    import java.io.InputStream;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.FileNotFoundException;
    import java.io.Writer;
    import java.sql.Connection;
    import oracle.jdbc.*;
    import oracle.jdbc.OracleResultSet;
    import oracle.sql.BLOB;
    import org.apache.log4j.Logger;
    import Util_Connect.DataBase;
    public class DisplayLOB extends HttpServlet
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
    static final Logger logger = Logger.getLogger(DisplayLOB.class);
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    //response.setContentType(CONTENT_TYPE);
    //PrintWriter out = response.getWriter();
    Connection conn = null;
    PreparedStatement pstmt = null;
    try
    conn = getConnection("wizard");
    //out.println("<html>");
    //out.println("<head><title>DisplayLOB</title></head>");
    //out.println("<body>");
    //out.println("<p>The servlet has received a POST. This is the reply.</p>");
    InputStream is=null;
    oracle.sql.BLOB blob=null;
    response.setContentType("application/msword");
    //response.setContentType("audio/mpeg");
    OutputStream os = response.getOutputStream();
    String term = "1";
    String query = "SELECT docdetail FROM testlob WHERE docno = 1";
    pstmt = conn.prepareStatement(query);
    ResultSet rs = pstmt.executeQuery();
    while (rs.next())
    blob=((OracleResultSet)rs).getBLOB(1);
    is=blob.getBinaryStream();
    int pos=0;
    int length=0;
    byte[] b = new byte[blob.getChunkSize()];
    while((length=is.read(b))!= -1)
    pos+=length;
    os.write(b);
    }//try
    catch (Exception se)
    se.printStackTrace();
    finally
    try
    pstmt.close();
    catch (Exception ex)
    System.out.println("Error closing pstmt "+ex.toString());
    //out.println("</body></html>");
    //out.close();
    private Connection getConnection(String dataBase)
    Connection conn = null;
    try
    conn = DataBase.getPoolConnection(dataBase);
    catch (Exception se)
    logger.fatal("Error getting connection: ",se);
    return conn;
    private void closeConnection(Connection conn)
    if (conn != null)
    try
    conn.close();
    catch (Exception se)
    logger.error("Error closing connection in get last imei",se);
    Here is JSP/Servlet
    <%@ page import="org.apache.log4j.*"%>
    <%@ page contentType="text/html; charset=ISO-8859-1" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>untitled</title>
    <title>Wizard SMS Interface</title>
    <link rel='stylesheet' type='text/css' href='main1.css'>
    <script language='JavaScript' src='copyright.js'></script>
    </head>
    <pre>
    <%
    //HTTP 1.1
    response.setHeader("Cache-Control","no-cache");
    //HTTP 1.0
    response.setHeader("Pragma","no-cache");
    //prevents caching at the proxy server
    response.setDateHeader ("Expires", 0);
    Logger logger = Logger.getLogger("co.za.mtn.wizard.administration.admin01.jsp");
    %>
    </pre>
    <body>
    <FORM ACTION="/WizardAdministration/uploadfile"
    METHOD="POST"
    ENCTYPE="multipart/form-data">
    <INPUT TYPE="FILE" NAME="example">
    <INPUT TYPE="SUBMIT" NAME="button" VALUE="Upload">
    </FORM>
    </body>
    </html>
    <font> <b>Copyright &copy;
    <script>
    var LMDate = new Date( document.lastModified );
    year = LMDate.getYear();
    document.write(display(year));
    </script>
    Mobile Telephone Networks.
    <p align="left"><i><b><font face="Georgia, Times New Roman, Times, serif" size="1"></font></b></i></p>
    package co.za.mtn.wizard.admin;
    import java.io.InputStream;
    import java.util.Enumeration;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.FileNotFoundException;
    import java.io.Writer;
    import java.sql.Connection;
    import oracle.jdbc.OracleResultSet;
    import oracle.sql.BLOB;
    import org.apache.log4j.Logger;
    import Util_Connect.DataBase;
    public class UploadFile extends HttpServlet
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
    //static final Logger logger = Logger.getLogger(UploadFile.class);
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    String headerName = null;
    Enumeration en = request.getHeaderNames();
    try
    while ( en.hasMoreElements() )
    Object ob = en.nextElement();
    headerName = ob.toString();
    System.out.println("Value for headerNAme is >"+headerName+"<");
    String aaa = request.getHeader(headerName);
    System.out.println("Value for aa is >"+aaa+"<");
    catch (Exception ex)
    System.out.println("Error in extracting request headers"+ex.toString());
    Connection conn = getConnection("wizard");
    BLOB blob = null;
    try
    conn.setAutoCommit(false);
    String cmd = "SELECT * FROM so_cs.testlob WHERE docno = 1 FOR UPDATE";
    PreparedStatement pstmt = conn.prepareStatement(cmd);
    ResultSet rset = pstmt.executeQuery(cmd);
    rset.next();
    blob = ((OracleResultSet)rset).getBLOB(2);
    //File binaryFile = new File("h:\\callcenterpilot.doc");
    //System.out.println("Document length = " + binaryFile.length());
    //FileInputStream instream = new FileInputStream(binaryFile);
    response.setHeader("Content-Type","application/vnd.ms-word");
    String contentType = request.getContentType();
    System.out.println("Content type received in servlet is >"+contentType+"<");
    ServletInputStream instream = request.getInputStream();
    OutputStream outstream = blob.getBinaryOutputStream();
    int size = blob.getBufferSize();
    byte[] buffer = new byte[size];
    int length = -1;
    while ((length = instream.read(buffer)) != -1)
    outstream.write(buffer, 0, length);
    instream.close();
    outstream.close();
    conn.commit();
    closeConnection(conn);
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    catch (Exception ex)
    System.out.println("Error =- > "+ex.toString());
    //out.println("</body></html>");
    //out.close();
    private Connection getConnection(String dataBase)
    Connection conn = null;
    try
    conn = DataBase.getPoolConnection(dataBase);
    catch (Exception se)
    System.err.println("Error getting connection: "+se.toString());
    return conn;
    private void closeConnection(Connection conn)
    if (conn != null)
    try
    conn.close();
    catch (Exception se)
    System.err.println("Error closing connection in get last imei"+se.toString());
    This is what the display servlet is showing when the JSP/Servlet insert the document
    -----------------------------7d31422224030e
    Content-Disposition: form-data; name="example"; filename="H:\(your name) Skills Matrix.doc"
    Content-Type: application/msword
    �� ࡱ � > ��     � � ���� � � ���������������������
    Tks
    Andre

    hello,
    there are multiple documents out there, describing the oracle reports server setup. try doc.oracle.com for documentation.
    also it is part of the online-documentation.
    you need to install 9iAS enterprise edition. the server is pre-configured and will listen to the url http://yourserver/dev60cgi/rwcgi60.exe
    passing only this url you will get a help-screen, describing the syntax.
    regards,
    the oracle reports team

  • Extract words from JSP into text file

    Hi,
    I have a big problem:
    I want to extract selected words from a jsp file.
    Following are found in one of my jsp file:
    E.g.
    1) <td width="217"><font face="verdana,arial" size=2>ORGANISATION UNIT NAME<font color="#FF0000"> <font
    id="fontMandatory">*</font></font>
    I want to retrieve "ORGANISATION UNIT NAME"
    2)errPrompt(frm.txtDesc, "Maximum length is just 100 character only");
    I want to retrieve "Maximum length is just 100 character only"
    I try String tokenising, then check that is the token ends with ">", then the next token is the one
    I want, then loop until "<" is found. BUT this would not work as there is no spacing between some of
    the tags and the words.(e.g. <p>abc)--> This cauese the whole token to be <p>abc, so the "abc" will
    not be extracted as it does not have a "ends with >" in front of it.
    Even with using ">" as a checking does not work for pop up messages, as it does not have tags(refer
    to e.g 2).
    Please reply a.s.a.p...
    Really urgent!!
    Thank You
    Michelle

    for extracting the HTML tags, u can use DOM/DHTML
    I dont remember the syntxes, how to use, but i know that it is possible, just go thru' the DOM/DHTML
    Regards,
    Ritesh

  • Specifying page parameters in an MS Word Doc using JSP

    Hi all,
    I have a JSP page which generates data and allows the user to open a Word Document with the generated data in it. I'm trying to figure out if there is a way to change the Page Setup parameters for the document. For example, I'd like a document that has 1 inch margins all around and uses a Landscape layout instead of Portrait.
    The user could just as easily change these parameters in Word after the document is open and save it to their hard drive, but I'd like to make things as simple for them as possible. Can I somehow pass my preferences to the Word document through the .jsp page that generates it?
    Thanks!

    Never mind, I figured it out :)
    I put this in the <head> tag in the HTML of the .jsp:
    <style>
       @page Section1
       {size:11.0in 8.5in;
       margin:1.0in 1.0in 1.0in 1.0in;
       mso-page-orientation: landscape;
       mso-paper-source:0;}
       div.Section1
       {page:Section1;}
    </style>And I put a div tag around the body of the document:
    <div class="Section1">
    </div>

  • Open up ms word in JSP

    When I set the content type to msword and try to display the page as a Word document, the images are all broken. I'm certain the images location are correct, because it displays properly when it's set as a normal JSP page. Any ideas?
    Thanks

    Are you trying to open a web page within the MS Word plug-in? Why?
    The original web page is defined in such a way that the web browser knows to go back to the server for the images it needs. The Word plug-in - which is launched if you set the content type to msword - does not know to do that because if you open any Word document on your computer, the computer assumes all of the files it needs are local.
    Or rather, let's say your file is called "foobar.jsp". From word's perspective, it's no different than calling...
    c:\msword.exe "c:\temporary internet files\foobar.jsp"In other words, there's no reason for it to not assume that everything it needs is within that one file.
    Convert your JSP output into a true Microsoft Word document first (see jakarta.apache.org/poi/index.html) in order to bundle the images into the document, and then send the document to the browser.

  • Diaplay  Word file stored in blob into a browser using JSP

    Dear All
    I have files stored in oracle table in a blob field.I store the files using forms 10g and webutil. I can upload the files and display them successfully in forms, however when i use JSP to retrieve the files and display them in Internet Explorer, I'm able to display the pdf files, bmp , jpg and video but I'm getting junk characters when I try displaying (word , excel , access or powerpoint files which might contain arabic Characters )
    the code I use to display the files is as follows :
    <%
    try
    Connection conn = null;
    String username=session.getAttribute("username").toString().toUpperCase();
    String password=session.getAttribute("password").toString().toUpperCase();
    String ip = "*****************";
    String sid = "***************";
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@"+ip+":1521:"+sid,username,password);
    String par = request.getParameter("LETTER");
    String par1 = request.getParameter("SERIAL");
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from TableName where PK1 like '"+par+"'"+" and PK2 like '"+par1+"'" );
    if (rs.next())
    Blob pic = null;
    byte[] blobBytesArray = null;
    OutputStream stream = response.getOutputStream();
    pic = rs.getBlob("BLOBFIELD");
    int len = new Integer( new Long( pic.length()).toString() ).intValue();
    blobBytesArray = pic.getBytes(1,len);
    if (blobBytesArray != null)
    if (blobBytesArray.length > 0 )
    stream.write(blobBytesArray) ;
    catch(Exception e)
    System.out.println("Exception: " + e.getMessage() + "<BR>");
    %>
    can you please guide me of how to display other file types.
    Best Regards.

    Hello,
    Ideally when you store the document put the content-type in a column and set the content type in your JSP. This will indicate to the browser what is the type of file and you should not have any issue with any type.
    Regards
    Tugdual Grall

  • Display telugu word in a jsp

    Hi,
    i have an assignment please help me in doing that. how to display a telugu word in a jsp page. can u please please help me ..........
    waiting for the reply
    thanks in advance

    gtRpr wrote:
    Telugu
    Use the Decimal values in the above link.
    &#DecimalValue;
    Place the following line within the head tags.
    <meta http-equiv=content-type content="text/html; charset=UTF-8">Eg:
    <html>
    <head>
    <meta http-equiv=content-type content="text/html; charset=UTF-8">
    </head>
    <body>
    //Below is the unicode values.  I added a space between # and 3 just so that it will display the code and not the symbol
    &# 3073;&# 3074;&# 3075;&# 3077;&# 3078;&# 3079;&# 3080;&# 3081;&# 3082;
    </body>
    </html>Results in
    &#3073;&#3074;&#3075;&#3077;&#3078;&#3079;&#3080;&#3081;&#3082;
    The values &# 3073; and so on would not be valid for charset=UTF-8

  • To open a pdf document or word document from a JSP into a new window

    Hi,
    How to open a PDF document or word document from a JSP into a new window. i.e say from a jsp when a hyperlink or button is clicked it should open a new window with the pdf document or word document in it.
    thanks in advance,
    radki_j

    Hi ,
    when i tried to use the below code to open my word document , it will open as html and with some garbage details. Doesnt open as word document. How to solve this kind of probem?Need advice urgently.
    Open Document

  • How can i passing chinese word parameter within jsp

    i got the issue of passing chinese parameter from one jsp to another jsp.
    my scenario is this : <br>
    i store the unicode(\u521B\u9020\u7528\u6237)in the .properties file. in 1.jsp i call the java to get the unicode from .properties file and it shows properly in 1.jsp(shows the chinese word - &#24744;&#30340;&#21517;&#23383;&#24050;&#32147;&#34987;&#20182;&#20154;&#20351;&#29992;!). then 1.jsp redirect to 2.jsp. i use request.getParameter("message") to get the chinese word. 2.jsp shows me the funny symbols(1�?). i need someone help me. below are the code of each jsp file.
    1.jsp
    %@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
         request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();     
         try {
             if (user1 != null) {
                   message+="1"+mpmservice.getLang(user.getLang(), "errmsg_username_exist")+"<br>";
                   bError=true;
              if(bError) {
                   response.sendRedirect("create_user.jsp?s=" + request.getParameter("s") + "&msg=" + message + "&name=" + name + "&description=" + description + "&phonenumber=" + request.getParameter("phonenumber") + privStr);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>     
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_do.jsp">
                   <input type=hidden name=msg value="<%=message%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><%=name%></td>
                             <td class="right"> </td>
                        </tr>
                        <tr>
                             <td class="left"> </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Create" type="submit" id="Create" value="<%=mpmservice.getLang(user.getLang(), "create_user")%>" />
                             </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Cancel" type="button" id="Cancel" value="<%=mpmservice.getLang(user.getLang(), "cancel")%>" onClick="location='create_user.jsp?s=<%=request.getParameter("s")%>&msg=<%=message%>&name=<%=name%>&description=<%=description%>&phonenumber=<%=request.getParameter("phonenumber")%><%=privStr%>'" />
                             </td>
                             <td class="right"> </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [[u]b]2.jsp[/b][/u]
    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
      request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();
         try {
             String message = request.getParameter("msg");
             System.out.println("in create_user.jsp  message>>>>>"+message);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>               
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_confirm.jsp">
                   <input type=hidden name=s value="<%=request.getParameter("s")%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><input class="middle" name="name" type="text" id="name" size="35" value="<%=name%>" /></td>
                             <td class="right">
                             <% if (message!=null && message!="" && message.startsWith("1") ) { %>
                                  <%=message.substring(1,message.indexOf("<br>")) %>
                                  <% message=message.substring(message.indexOf("<br>")+4,message.length()); %>
                             <% } %>
                              </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [u].properties file[/u]
    errmsg_username_exist=\u60A8\u7684\u540D\u5B57\u5DF2\u7D93\u88AB\u4ED6\u4EBA\u4F7F\u7528!
    [\code]
    i really appreciate whoever reply this issue.
    thanks a lot

    i got the issue of passing chinese parameter from one jsp to another jsp.
    my scenario is this : <br>
    i store the unicode(\u521B\u9020\u7528\u6237)in the .properties file. in 1.jsp i call the java to get the unicode from .properties file and it shows properly in 1.jsp(shows the chinese word - &#24744;&#30340;&#21517;&#23383;&#24050;&#32147;&#34987;&#20182;&#20154;&#20351;&#29992;!). then 1.jsp redirect to 2.jsp. i use request.getParameter("message") to get the chinese word. 2.jsp shows me the funny symbols(1�?). i need someone help me. below are the code of each jsp file.
    1.jsp
    %@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
         request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();     
         try {
             if (user1 != null) {
                   message+="1"+mpmservice.getLang(user.getLang(), "errmsg_username_exist")+"<br>";
                   bError=true;
              if(bError) {
                   response.sendRedirect("create_user.jsp?s=" + request.getParameter("s") + "&msg=" + message + "&name=" + name + "&description=" + description + "&phonenumber=" + request.getParameter("phonenumber") + privStr);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>     
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_do.jsp">
                   <input type=hidden name=msg value="<%=message%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><%=name%></td>
                             <td class="right"> </td>
                        </tr>
                        <tr>
                             <td class="left"> </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Create" type="submit" id="Create" value="<%=mpmservice.getLang(user.getLang(), "create_user")%>" />
                             </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Cancel" type="button" id="Cancel" value="<%=mpmservice.getLang(user.getLang(), "cancel")%>" onClick="location='create_user.jsp?s=<%=request.getParameter("s")%>&msg=<%=message%>&name=<%=name%>&description=<%=description%>&phonenumber=<%=request.getParameter("phonenumber")%><%=privStr%>'" />
                             </td>
                             <td class="right"> </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [[u]b]2.jsp[/b][/u]
    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
      request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();
         try {
             String message = request.getParameter("msg");
             System.out.println("in create_user.jsp  message>>>>>"+message);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>               
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_confirm.jsp">
                   <input type=hidden name=s value="<%=request.getParameter("s")%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><input class="middle" name="name" type="text" id="name" size="35" value="<%=name%>" /></td>
                             <td class="right">
                             <% if (message!=null && message!="" && message.startsWith("1") ) { %>
                                  <%=message.substring(1,message.indexOf("<br>")) %>
                                  <% message=message.substring(message.indexOf("<br>")+4,message.length()); %>
                             <% } %>
                              </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [u].properties file[/u]
    errmsg_username_exist=\u60A8\u7684\u540D\u5B57\u5DF2\u7D93\u88AB\u4ED6\u4EBA\u4F7F\u7528!
    [\code]
    i really appreciate whoever reply this issue.
    thanks a lot

Maybe you are looking for

  • I have configuration file for VECTOR CAN and want to port to NI CAN card

    Hello, I have CAN analyzer with for Vecror CAN card. Now I want to use the NI CAN analyzer for the same application. What are all teh files that can be compatible with NI CAN card. I have .dbc .asc .ccp files with me, please suggest on having the sam

  • HELP ME ! Itunes wont load !

    I am so annoyed ! I click on itunes on my dell inspiron and the mouse will turn to the blue swirly thing and then it will just go back to the mouse and itunes wont pop up! please please help me! should i re-download ???

  • Created by (submitted by) varaible

    I would like to include the created (submitted) by variable in the change management email notification. Does anyone know if this possible – I am noob to service manager so any help would be great.

  • Setting contentType...

    A very simple question: how do you set the content type so I can use html formatting? I saw somewhere it's like this msg.setcontent("text/html"); but that doesnt seem to work...

  • Port Flapping Alerts from PI2.1

    Hi All. We have a significant number of a particular type of device on our network which during a reboot cycle causes the port to drop 3 times in the process. Since migrating to PI 2.1 we now receive 'critical' alarm e-mails for port flapping every t