Hi
I want to display text and image both on the same jsp page.
but the code display only image, which is retrieve from database.
can i display both on same jsp page.

all data retrieve from database with image as blob.

please help me..

Easy. But not the way you think it's done.
You can not mix text and binary output in a single http stream, it has to be 2 requests.
The JSP displays the text, includes a link to a servlet that serves the image.
Of course the JSP doesn't do anything at all with Java code, it just parses the data generated by another servlet.

i am developing website using jsp and html n database of mysql
i want the code written in html n jsp to upload files on my web page
files should include all types i.e. image,video,ppt,word doc etc.

thank u very much
i will try this code n reply u soon
............
i really don't hav words to thank u....
see u later............

If roseindia says something, it's almost certainly wrong or at the very least highly inaccurate.

Hi Have you try roseindia?. There are a big helpful site for Java technology.
when i was new in java i learned many concept related to web or java technology by this site. and also at this time Ok....
try it then do comment..
thanks for advice.

Off topic - I agree with jwenting roseindia is worst place to try and learn something.
1) There is not structural organization of topics
2) Many of examples are out of date, plenty of them are done with poor organization of even basic MVC in mind
3) there are plenty of tutorials stolen from books, online tutorials without acknowledging rightful author

So please in the future do not suggest this website as it shunned upon as example of what everything can be done wrongly.

And pretty much everything they tell you is fundamentally flawed.

<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
   <%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
   <%@ page import="org.apache.commons.fileupload.*"%>

i got an error tht these packages does not exist
in netbins 5.0
i will try once again...
but can u suggest me better compilar thn netbins 2 run my jsp codes
n frm where do i can get it??

1) Please use code tags when posting any code
2) Did you actually downloaded the Commons FileUpload package and included in your project?
3) Every forum member is asked to used full sentence English. Chat/SMS type of writing is not welcome.
4) NetBeans is not compiler but IDE. If you do not like it you can use IntelliJ IDEA, Eclipse or command line
5) The tutorial that you are trying to follow is about getting data from client to server, where from your description of problem you want from server do client you are wasting your time with it...

<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
   <%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
   <%@ page import="org.apache.commons.fileupload.*"%>

i got an error tht these packages does not exist
in netbins 5.0
i will try once again...
but can u suggest me better compilar thn netbins 2 run my jsp codes
n frm where do i can get it??

hi you must download apache common file upload and i/o library from apache .org. then put all jar file in your class path directory.

i have been use this code it upload all type of document. doc,image,pdf,txt but i am not sure about video.

i am building a website in jsp+html using mysql database.
i want to allow user to uplod files of all type i.e. ppt,word doc,image,audio,video files on web page...
i tried the codes written in roseindia ...// in netbins5.0
but it do not hav certain packages used in those codes.......
it gives error like those packages do not exits... they are

<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.*"%>

plz help me

Already answered in post 11 and please start using code tags and stop reposting that useless roseindia link

u can display both text and image in the same jsp page by using <iframe> tag
u can write like this in your jsp page

<iframe src="url" style="width: 150%; height: 500px"></iframe>

thnnks priya but i dont suppose it will be useful for me now. I asked this question a long time ago and i think i have resolved this problem. but ok no problem good job... keep it up....... :)

display image from database along with text in jsp
im tring to display image from database with som text but i didn't get it and also im getting only one image please help me im new in jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*" %> 
<%@ page import="java.io.*"%> 
<%@ page import="java.util.*"%> 
<!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>image</title>
</head>
<body>
<% 
Blob image=null;
byte[] img=null;
Connection con=null;
Statement st=null;
ResultSet rs=null;
 String id=request.getParameter("id");
 int i=0;
try{

   Class.forName("com.mysql.jdbc.Driver").newInstance(); 
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","password"); 
    st=con.createStatement();
   rs=st.executeQuery("select bimage from phototable");
   while(rs.next())
   {
       image=rs.getBlob(1);
       img=image.getBytes(1,(int)image.length());

    response.setContentType("image/gif");
  OutputStream o=response.getOutputStream();
  out.println("<p>its working</p>");
  %> 
<table border="2"><tbody><tr><td>
<p>hiiiiii</p>

   <img src="<%rs.getBlob(1);%>" width="10" height="20"></td></tr>

 <% 
  o.flush();

  o.close();

  i++;
   }
  out.println("success");
   } 
   catch(Exception e) 
   { 
     out.println(e.toString());

   } 


%> 

<tr><td><p>hiiiiii</p></td><td><p>hiiiiii</p></td><td><p>hiiiiii</p></td></tr></tbody></table>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.