jsp image display
this is my saveImage.jsp file:
<%
ServletContext context = pageContext.getServletContext();
String initPath = context.getInitParameter("file-upload");
String filePath=initPath;
String path=(request.getRequestURL().toString());
String urlPath=path.substring(0,path.lastIndexOf('/')+1)+"files/";
String userName=(String)session.getAttribute("username");
String password=(String)session.getAttribute("password");
String userId="";
String query="";
userName="jar";
password="gg";
// String connectionURL = "jdbc:mysql://localhost:3306/student";
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","12345");
Statement st=con.createStatement();
//System.out.println("session attribute"+userName+"password"+password);
String ImageFile="";
String itemName = "";
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
out.println("File Not Uploaded");
}
else
{
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try
{
items = upload.parseRequest(request);
}
catch (FileUploadException e)
{
e.getMessage();
}
Iterator itr = items.iterator();
while (itr.hasNext())
{
FileItem item = (FileItem) itr.next();
if (item.isFormField())
{
String name = item.getFieldName();
String value = item.getString();
if(name.equals("ImageFile"))
{
ImageFile=value;
}
}
else
{
try
{
itemName = item.getName();
File checkDir = new File(filePath);
File savedFile=null;
if(checkDir.exists())
{
itemName=itemName;
savedFile= new File(filePath+itemName);
}
else{
checkDir.mkdir();
savedFile= new File(filePath+itemName);
}
item.write(savedFile);
String updateQuery="update stu_info set image_path=? where username=? AND password=?";
PreparedStatement pstmt=con.prepareStatement(updateQuery);
pstmt.setString(1,itemName);
pstmt.setString(2,userName);
pstmt.setString(3,password);
int id = pstmt.executeUpdate();
out.print("success");
}
catch (Exception e)
{
System.out.println("error message is"+e.getMessage());
out.print("Error"+e.getMessage());
out.print("error");
}
}
}
}
}
catch (Exception e){
System.out.println("error message is"+e.getMessage());
out.print("error");
}
%>
how can i create session fo userName and password so that i dont have to write particular userName and password on line 10 and 11
View Answers
Related Tutorials/Questions & Answers:
display image on jsp is downloading on
jsp.
show i can open it. but i want to
display that
image on
jsp...
display image on jsp how to
display image from database which path is coming in string.
i want to
display image and its discription and price
image display - JSP-Servletimage display how to
display image that store in mysql database... column have BLOB datatype.... Hi Friend,
Please visit the following link:
http://www.roseindia.net/
jsp/retrieve-image.shtml
Thanks
Advertisements
display image using jspdisplay image using jsp
display image using
jsp and phonegap on emulator of eclipse
Here is a simple
jsp code that displays an
image on browser.
<%@ page import="java.io.*" %>
<%@page contentType="
image/gif
Jsp Image DisplayJsp Image Display Hi,i need to
display image in a Box like in profile photo,when i click on the browse button,file gets open and the selected
image... to save it in a database....Kindly post
JSP codes..Its Urgent,
I m very thankful t
image display in jsp - Java Beginnersimage display in jsp i uploaded the
image and how can i print that
image in next
jsp page.... Hi friend,
read for more information,
http://www.roseindia.net/
jsp/file_upload/employee_upload_profile_image.shtml
jsp image displayjsp image display this is my saveImage.jsp file:
<%
ServletContext context = pageContext.getServletContext();
String initPath...);
String updateQuery="update stu_info set
image_path=? where
JSP:select image for db and display in image tagJSP:select
image for db and
display in
image tag Hi, i am new to this forum.
My query is that, i am trying to
display image in
image tag but i am...();
response.setContentType("
image/jpg");
response.getOutputStream().write(rb,0,len
JSP:select image for db and display in image tagJSP:select
image for db and
display in
image tag Hi, i am new to this forum.
My query is that, i am trying to
display image in tag but i am...);
response.getOutputStream().flush();
}
i think, this code will
display image JSP:select image for db and display in image tagJSP:select
image for db and
display in
image tag Hi, i am new to this forum.
My query is that, i am trying to
display image in tag but i am...);
response.getOutputStream().flush();
}
i think, this code will
display image how to display one image on jsp through javahow to
display one
image on
jsp through java Hi,
I wanted to
display one
image on my
jsp file like social networking sites. But the scenario...://upload/image.jpg . what is the procedure to get that and
display on my
jsp page
image display for uploading
image in ms access database and also seen the result of displaying
image from access database but Sir I want that how I
display image from database...
image display hello sir this is saurav srivastav, I am developing my
pre Page load display an image loading - JSP-Servletpre Page load
display an
image loading hi,
We have requirement... to
display a loading
image. How to achieve this requirement.
Thanks
Manu Hi Friend,
Do you want to
display image before loading page?
Please clarify
Display imageDisplay image How to Pass
image from html to
jsp and
display that
image using
jsp
Here is an example that pass an
image path from the html page to
jsp page and
display it.
1)page.html:
<%@ page language="java
image display to
display in
image from databse plz help me i will wait for ur reply...
image display sir the answer which you have sent to me is already I have I want to know that the syntax which you have writen for
display image display to
display in "div
image from databse /div" plz help me i will wait for ur reply...
image display sir the answer which you have sent to me is already I have I want to know that the syntax which you have writen for
display Display image on JSP page using XML Display image on
JSP page using XML
... can
display a
image on
JSP page by using XML.
This example will examine how to parse and expose XML
information using the JAXP with a
JSP page
image displayimage display Hai Friends.....
Actually I uploaded filepath into database and
image into a folder. Now i want to show that
image as my profile photo. How it is?...Friends Can you help me?
Thanks in advance to take time
image displayimage display Hai Friends.....
Actually I uploaded filepath into database and
image into a folder. Now i want to show that
image as my profile photo. How it is?...Friends Can you help me?
Thanks in advance to take time
Display Blob(Image) from Mysql table using JSP Display Blob(
Image) from Mysql table using
JSP
In this section, we will
display blob data(
image) from Mysql database table
using
JSP code.
A Blob stores...;);
return;
}
ADS_TO_REPLACE_6
//
display the
image Image display in pdfImage display in pdf i am trying to
display a
image in pdf using xsl fo but " [ERROR] Error while creating area : Error with
image URL: images... go through the following link:
Display image in pdf
image display - Java Beginnersimage display i need to
display all the images from the folder and i dont want give the
image path.dynamically it should
display. please help Hi friend,
Code to help in solving the problem
var
image display - Java Beginners; %><html><head><title>Retrive
Image with jsp</title></head><body><img src="/
jsp/red_rose2.gif" name="...;--------------------------------------read for more information,http://www.roseindia.net/
jsp/file_upload/Sinle
image in jsp - JSP-Servletimage in jsp i m storing path of
image in my database.. but when i m trying to
display image using that path
image is not getting... i m storing path like c:\
image\a.jpg ... and i m using tag... how to get
Display Image in Java
Display
Image in Java
...): Pass the boolean value as true to
display the
image or Vice-Versa. Here we are passing the boolean value as true to
display the
image on the frame
how to display the image in center - Ajaxhow to
display the
image in center i want to dispaly the
image as center of the screen using javascript..while i am clicking the button ..any one give me the code for this one
How to retrieve and display image from database in Java? on the web page. My application is in Java/
JSP.
How to retrieve and
display image...How to retrieve and
display image from database in Java? Hi,
I am....
Please check the it at How to store and retrieve
image from database in
JSP J2me image display - Java BeginnersJ2me
image display How can i
display a jpeg
image in j2me Hi Friend,
Please visit the following links:
http://www.roseindia.net/j2me/append-image.shtml
http://www.roseindia.net/j2me/image-item-example.shtml
Display Java in JSPDisplay Java in JSP please i need urgent help. How can i
display Java Applet created in netbeans in
JSP?.
the Application involves MYSQL Database connection. Thanks
Display Image on JDesktopPaneDisplay Image on JDesktopPane
In this section, you will learn how to retrieve an
image from the database and
display it on the JDesktopPane. You can see... != null) {
JFrame f = new JFrame();
f.setTitle("
Display Image From
How to display date in JSP?How to
display date in
JSP? How to create a simple
JSP program which displays date on the page?
Thanks
Hi,
You should import...() %>
Check complete tutorial at How to Create
JSP Page?
Thanks
Jsp Image prob - JSP-ServletJsp Image prob I m working on a project i which i have to upload a
image in
jsp to database and then on next page i will show that
image from database so what should i do as i have done first phase
java image display - Java Beginnersjava
image display How to
display images in the folder dynamically with out using database using java and jsp Hi friend,
Code to help in solving the problem
var galleryarray=new Array
Image preview - JSP-ServletImage preview How to show the preview of the
image when we select the
image through browse button in
JSP page before storing it in the application... select the
image using the file type button i want to dynamically show
Show image and text on same jsp pageShow
image and text on same
jsp page Hi all,
I have to
display image and text on the same
jsp page.
The text and
image are both retrived from mysql database.
The
image is shown correctly on seperate
jsp page but when shown