Use of BLOB in jsp
i have inserted a pdf file in database using the blob data type.Now i want to show the pdf file in jsp selecting it from database....can any body suggest what to do...??
Thanx in advance
thanks evnafets...
i tested it by using servlet...and in the blob i need to store a pdf file ..but here i tested for a image file...so in the blob field the image file is there now.....Still it is not working ..only the download link is coming but the blank image is downloaded...can u suggest..
my code is like..
String SqlQuery="select invoice_blob from web_self_care_invoice where account_number ="+acno+"";
ResultSet rs=st.executeQuery(SqlQuery);
System.out.println("PDFServlet.java: after execution of query");
rs.next();
String fileName="logo_large.gif";
response.setContentType("image/gif");
response.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
response.setHeader("cache-control", "must-revalidate");
ostr = response.getOutputStream();
Blob bl = rs.getBlob("invoice_blob");
buff = bl.getBytes(1, (int)bl.length());
ostr.write(buff);
Thanks in advance
Similar Messages
-
How to use mxml in a jsp file?
I'm trying to use flex in a .jsp file. I followed the
suggestion that I use the Flex 2 Tag library as suggested by this
link:
http://labs.adobe.com/wiki/index.php/Flex_2_Tag_Library_for_JSP#Download_and_Installation
but I couldn't find it. I also downloaded LiveCycle Data Services
ES but couldn't find the flex-bootstrap.jar.
I have a simple example:
<!--<%@ taglib uri="FlexTagLib" prefix="mm" %>-->
Use the <mxml> tag to insert a Flex application in an
existing JSP page. The following example shows the <mxml> tag
with the source attribute to include an external MXML file:
<mm:mxml source="CustomerServiceChat.mxml"/>
Alternatively, you can use the <mxml> tag with inline
MXML source code, as the following example shows:
<mm:mxml>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns="*">
<mx:Text label="Hello World">
</mx:Application>
</mm:mxml>
I also added the following code in my web.xml:
<taglib>
<taglib-uri>FlexTagLib</taglib-uri>
<taglib-location>/WEB-INF/lib/flex-bootstrap.jar</taglib-location>
</taglib>
and obviously I get an error because I don't have the
flex-bootstrap.jar file. Please let me know how this can be
corrected. Thanks in advance!Adobe Newsbot hopes that the following resources helps you.
NewsBot is experimental and any feedback (reply to this post) on
its utility will be appreciated:
Adobe - Developer Center : Flex quick start guide for PHP
developers:
Apr 30, 2007 ... In this example, I changed the result data
type to XML with E4X support by setting .... In Flex you would
download a file using this code:
Link:
http://www.adobe.com/devnet/flex/articles/php_getstarted.html
2d. Tutorial - Flex 3 Getting Started - Adobe Learning
Resources:
See Calling XML Web Services over the Web Using the Web
Service References ... For information on integrating PHP and Flex
using AMF to encode the data,
Link:
http://learn.adobe.com/wiki/display/Flex/2d.+Tutorial
Mike Potter: Flex and PHP - A simple sample:
I have other example with PHP and MySql and give the same
error, and a example .... Flex Data Services... I choose None (???)
because I work with php and
Link:
http://blogs.adobe.com/mikepotter/2006/02/flex_and_php_a_1.html
Adobe - Developer Center : Transmitting data between Flex and
PHP:
Sep 4, 2007 ... Now that the user interface is set up and
ready to go you can add the HTTP services to go ask for the data
from the PHP code. In Flex you
Link:
http://www.adobe.com/devnet/flex/articles/flex_php_json.html
Integrating Adobe Flex and PHP:
Mar 1, 2006 ... The first step is to download Flex Builder
2.0 from the Adobe labs ... For example, you could use this same
PHP script to pass data to a
Link:
http://devzone.zend.com/article/11-Integrating-Adobe-Flex-and-PHP
Disclaimer: This response is generated automatically by the
Adobe NewsBot based on Adobe
Community
Engine. -
How to use switch statement in JSP?
Hi,
I am using switch satement in jsp.
the code as follows:
switch(flag)
case 1: query="select * from cust";
break;
case 2: query="select * from cust where minp="+mini+"and maxp="+maxi;
break;
default: query="";
out.println(query);but, i am getting some number format exception. I don't know where i am going wrong.
Please help
Regards,
AshviniI got the solution
Thanks anyways
Regards,
AShvini -
Hi all,
I am using return statement in JSP page after a redirect to stop executing that page. If the data bean is not present then it must go to previous page. When this return statement is executed the previous page is displayed but url in browser remains same. Why it is so ?. Is there any other way to tell a JSP page to stop executing and redirect to another page.
rgds
Antony PaulHi Antony,
do you use the "forward()" method or the "redirect()" method???
rgds
Howy -
I wan't to know the advantages and disadvantages of using JavaBeans in a JSP page.
Like for example general traditional approach for a database connection
is to create a connection and access the database from that and close the connection
at the end of the page, instead of the If I use a common connection bean for making connections,
is that suggestable and then when should i close the connection then.
One good application of JavaBeans is using a Set and Get methods for form fields in
a registration form to get back the values.
So may i know how best can we use the JavaBeans other than this application.
ThanX in advance,
kiran
[email protected]I believe putting processing and query code in the JavaBean was one of the reasons for putting JavaBeans support in JSP in the first place. The original idea was to use the setXXX methods to populate the bean's data from the posted form, then do the processing (or database query), then use the getXXX methods to display the bean's data.
Efficiency-wise, it's exactly the same as putting all the code in-line in the JSP page (actually, it might be a bit slower, because of the reflection required to do it.) Code-wise though, it makes the JSP easier to read.
Of course, we have EJBs now too, which tie very closely and can match database queries almost one-to-one, one way to incorporate these is inside the JavaBean you reference from the JSP, another way from a servlet you redirect the JSP to, etc... -
How to use connection pooling in jsp?
I'm new to world of JSP. I'm developing web application using Oracle 8i and JSP to implement it. I'm using jakarta-tomcat server for this purpose.
I'll frequently access the database. so I want to use the connection pooling.
Can anybody explain the simple procedure to use it
thanxHello syyuen,
Please help me, here iam sending u my server.xml , web.xml and servlet
application. I put classes12.jar in tomcat/common/lib. and above servlet
class application under tomcat/webapps/root/web-inf/classes
and this is a simple servlet program for getting connection from the
connection pool of tomcat using tyrex..
my oracle database name is "myuser" and password is "mypass"
either u check my server.xml or tell me where under which tag should i
place <Resource...> tag in server.xml and should i need to modify any
other places..??
server.xml
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Tomcat Stand-Alone Service -->
<Service name="Tomcat-Standalone">
<!-- Non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>
<!-- AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
<!-- Top level container in our container hierarchy -->
<Engine name="Standalone" defaultHost="localhost" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally
<Realm className="org.apache.catalina.realm.MemoryRealm" /> -->
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->
<!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/authority?user=test;password=test"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@oracle:1521:ORCL"
connectionName = "mail"
connectionPassword = "mail"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
<!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL="jdbc:odbc:CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!-- Define the default virtual host -->
<Host name="localhost" debug="1" appBase="webapps" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<!-- Tomcat Root Context -->
<!-- <Context path="" docBase="ROOT" debug="0"/> -->
<!-- Tomcat Manager Context -->
<Context path="/manager" docBase="manager" debug="0" privileged="true"/>
<!-- MY CONTEXT HERE -->
<Context path="/localhost" docBase="localhost" debug="0" reloadable="false" override="true">
<Resource name="jdbc/myConnection" auth="SERVLET" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/myConnection">
<parameter><name>user</name><value>myuser</value></parameter>
<parameter><name>password</name><value>mypass</value></parameter>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@oracle:1521:ORCL</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>32</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
</ResourceParams>
<!-- END OF MY Context, Oracle username=myuser,password=mypass -->
<!-- i pasted this context from somebody . should i need whole context or resource name in that...???? -->
<!-- Tomcat Examples Context
<Context path="/examples" docBase="examples" debug="0" reloadable="true" crossContext="true">
-->
<!--
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_examples_log." suffix=".txt" timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity" home="com.wombat.empl.EmployeeRecordHome" remote="com.wombat.empl.EmployeeRecord"/>
<Environment name="maxExemptions" type="java.lang.Integer" value="15"/>
<Parameter name="context.param.name" value="context.param.value" override="false"/>
<Resource name="jdbc/EmployeeAppDb" auth="SERVLET" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/EmployeeAppDb">
<parameter><name>user</name><value>sa</value></parameter>
<parameter><name>password</name><value></value></parameter>
<parameter><name>driverClassName</name><value>org.hsql.jdbcDriver</value></parameter>
<parameter><name>driverName</name><value>jdbc:HypersonicSQL:database</value></parameter>
</ResourceParams>
<Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
-->
</Context>
</Host>
</Engine>
</Service>
<!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">
<Connector className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>
<!-- Replace "localhost" with what your Apache "ServerName" is set to -->
<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally -->
<Realm className="org.apache.catalina.realm.MemoryRealm" />
</Engine>
</Service>
</Server>
web.xml
<web-app>
<servlet>
<servlet-name>conServlet</servlet-name>
<servlet-class>conServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>conServlet</servlet-name>
<url-pattern> /conServlet </url-pattern>
</servlet-mapping>
<resource-ref>
<description> Resource reference to java.sql.Connection
factory defined in server.xml
</description>
<res-ref-name>jdbc/myConnection</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
servlet application
DataSource ds = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/myConnection");
conn = ds.getConnection();
out.println("conn : " + conn); -
How to use session object in jsp
hi all
marry christmas
can anyone plz tell me how to use session obect in jsp
rachna
Message was edited by:
rachna_arora82hi rachna,
JSP has a default(implicit) session object...... use the getSession(true) method on the session object and then going u can either get or set attributes depending on the requirement
That was in general and now with the issue u have got..... what u can do is that the u can create session for every user who logs in and when he/she tries to login again then u can probably check for the existing session object in the JSP and perform the logic as required..... any clarifications plzzzzzzz let me know
Thanks n Regards
Naveen M
Message was edited by:
Novice_inJAVA
Message was edited by:
Novice_inJAVA -
How to use SSL Technology in JSP.
Can anybody Tell me that How to use SSL Technology in JSP ?
I am using Apache Tomcat 5.0.28 Server.
How to configure the Tomcat server so that it will access any web application supported by Tomcat via SSL ?
Thank you very much in advance.The JSP does not need to know that the request is coming over SSL. If the application must be over SSL, but the server also allows non-SSL communication, then, like I said, you need to build in a Filter that will check if the incoming request is an https or http request and redirect to the https url if the request was http. And you can do that using the method listed in the previous post. As far as setting up the SSL certificate for Tomcat to use, refer to the Tomcat Documentation that comes with the server. Other than those two things, you don't need to know anything else about SSL inorder to run an SSL application through a Tomcat server (or any other enterprise server either, for that matter), but do an internet search for SSL and maybe one or two other keywords that apply to your situation and you should find plenty that will help.
-
sir
plz tell me how to use custom tag in jsp.plz describe it.
i will be thankful to uDo you want to use taglibs or develop custom tags? Either way take a look at these:
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags.html
http://www.stardeveloper.com/articles/display.html?article=2001081301&page=1
http://www.onjava.com/pub/a/onjava/2000/12/15/jsp_custom_tags.html
http://jakarta.apache.org/taglibs/tutorial.html
http://www.ibm.com/developerworks/edu/j-dw-java-custom-i.html
http://www.herongyang.com/jsp/tag.html -
Oepe-12.1.2.1-kepler how to use ADF Templates in JSP page
Hi all,
I use oepe 12.1.2.1 kepler 4.3 and creating JSP page but I can't see any ADF Rich Faces Page in JSP Templates Page of Preferences Dialog. How to use ADF Templates in JSP page?
Thanks,
ThomasSelect the JSP Templates link. Is the ADF Rich Faces Page template listed? Refer Creating the Login Page/4.
Introduction to the Oracle Enterprise Pack for Eclipse (OEPE) IDE -
Hi, how to use URL encoding in jsp
hi, how to apply URL encoding in jsp for a string, could u pls suggest some ideas to use URL encoding in jsp
thank you in advancehi, thnx for the reply, but my problem is to use url encoding method
i would u like to know how to represent in jsp program i have asp code some thing like this
href='/project/tel_number.asp?team=<%=DbRecTeam("id")%>&name=<%=Server.URLEncode(DbRec("name"))%>'
i would like to know how replace that Server.URLEncode stmt in jsp, could u pls suggest some equivalent method for the above stmt
thanx in advance -
How to use connection pool in jsp/servlet ?
I found I can "lookup" it in either java beans/servlets/JSP using JNDI. why?
what is the best practice to use it in a jsp/servlet web app considering JNDI lookuping expensive?
Thanks!
Bo
Edited by: BobXu on Nov 17, 2008 2:27 PM
Edited by: BobXu on Nov 17, 2008 2:32 PMHuh?
You can lookup a JNDI resource from anywhere in java code you want to. As long as you have a repository set up to search on :-)
Of course whether that resource is available or not is a different matter. If you let the server set up the JNDI resource for you, then you can't run it standalone outside the server without something else setting the same thing up :-)
So its not so much a limitation of beans, but just the environment you run the code in.
Best practice? Don't write sql queries in JSP pages :-)
For the rest you might consider the DAO pattern. Or ignore SQL altogether and let hibernate do the work there for you.
Cheers,
evnafets -
How to use bind variables in JSP applications ?
Hi,
How will i use bind variables in jsp applicaions ?
Any links that give a clear understanding ?
TIA,
jjHi,
Try this link, this may help you.
http://www.oracle-base.com/articles/misc/WebScriptingForOracle.php
Thanks -
How to use protected method in jsp code
Could anyone tell me how to use protected method in jsp code ...
I declare a Calendar class , and I want to use the isTimeSet method ,
But if I write the code as follows ..
========================================================
<%
Calendar create_date = Calendar.getInstance();
if (create_date.isTimeSet) System.out.println("true");
%>
============================================================
when I run this jsp , it appears the error wirtten "isTimeSet has protected access in java.util.Calendar"The only way to access a protected variable is to subclass.
MyCalendar extends Calendar
but I doubt you need to do this. If you only want to tell if a Calendar object has a time associated with it, try using
cal.isSet( Calendar.HOUR ); -
What is use of % symbol in JSP
What is use of % symbol in JSP? Please reply
What is use of % symbol in JSP? Please replySome people on this thread have provided you good
answers.
You may also want to know that the new way ofwriting
JSPs is with JSTL and scriptlets <% anything that
goes here is a scriptlet %> are discouraged.
But it's good to get basic foundation inscriptlets
too incase there's legacy JSP code.why would you need a foundation in scriptlets,
though? if it's legacy code, it's already there, and
it's just java. if you can't work out that the stuff
that looks like java code in a legacy JSP actually
is java code, you're in trouble. and wouldn't
part of the maintenance be to refactor the scriptlets
out?It's not really just Java IMO because JSP has additional concepts like
implicit objects such as page, request, session, out etc ---- a newbie who knows Java won't have a clue when the come across the implicit objects and can't find where they were declared.
Also the concept of directives is not in Java Classes but on in JSPs.
JSP has some features that would be new or confusing to someone who has only worked with Java, therefore a newbie to JSP would be better off learning JSP concepts.
-regards
appy
Maybe you are looking for
-
Why does my webcam transmit fine in html5 in Chrome, but not in Firefox?
On every website I try, Firefox does not support getusermedia, so I cannot transmit audio and video data from my Windows 8.1 tablet in html5. Thus, I cannot use Firefox Hello. I have tried tinkering with numerous settings in about:config, but nothing
-
Why is the jextfield on the jframe so small. Also How do I update the textField of MyButton JFrame from JButtonActionListener? import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextField; public cl
-
My dvd burner/ cd-rom will not accept
Everytime I try to insert a disc, it rotates a couple of times and then gets spit out. Nothing stays in, not dvds, blanks, or music cds. Is it time for me to get a new drive?
-
Problem #1. The first top bar has a firefox logo at upper left corner and the words "Ask a Question/Mozilla Support-Mozilla Firefox" are on the logo's right side. The first top bar has minimize, overlap and close buttons at the upper right corner. Wh
-
I go to the "windowsphone.com" and logon, but I can't get the find my phone to work.