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
Ads
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-Servlet
image 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 jsp
display 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 Display
Jsp 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
jsp image display
jsp 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 tag
JSP: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 tag
JSP: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 tag
JSP: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 java
how 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
Display image
Display 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
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 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
image display
image 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 display
image 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 display in pdf
Image 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
Display Java in JSP
Display 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 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 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
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
Show image and text on same jsp page
Show
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