Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet jsp image display

Have Programming Question? Ask it here!
 
 
 


HIMANSHU PANT
jsp image display
0 Answer(s)      9 months ago
Posted in : JSP-Servlet


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


Advertisement
View Answers

Related Tutorials/Questions & Answers:
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
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
Advertisements
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
image display in jsp - Java Beginners
image 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: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
Retrview image from sqlserver2000 and display in jsp - JSP-Servlet
Retrview image from sqlserver2000 and display in jsp  How to retreview image from sqlserver2000 to jsp? pls give the solution i am using Tomcat 4... for more information, http://www.roseindia.net/jsp/ Thanks
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
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
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
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
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
Upload and display image and text records using JSP and Oracle
Upload and display image and text records using JSP and Oracle  Hi all, I'm using JSP and Oracle 10g. I could retrieve and display records from database. But i couldnot retrieve and display image. I want to store
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
pre Page load display an image loading - JSP-Servlet
pre 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
How display a Image on servlet from file upload - JSP-Servlet
How display a Image on servlet from file upload  Dear Sir, I were ask a question that How display the Image on servlet through file upload. Today I get your answer. But Sir, It code not display the image on servlet
How display a image on servlet from file upload - JSP-Servlet
How display a image on servlet from file upload  Dear Sir, My issue is: How display a image on servlet from file upload I receive your answer today. That is: Answers Hi friend, I am sending running code. Image
How display a image on servlet from file upload - JSP-Servlet
How display a image on servlet from file upload   Dear Sir, My Question is: How display a image on servlet from file upload Your Answer: Hi... reason is inaccessible Thanks Sir, But Servlet page nothing display any type
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
How display a Image on Servlet from file upload - JSP-Servlet
How display a Image on Servlet from file upload  Dear Sir, My requirement is I want to display a Image on Servlet from File Upload. But It not display on servlet,Its appear a downloaded form and downloaded on disk when click
display an image on my page
display an image on my page  How can I display an image on my page
how to display image with listview
how to display image with listview  How can i display the list view with the related images from database
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 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; } // display the image response.setContentType("
image display - Java Beginners
image 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
image display   "" ...*" %><html><head><title>Retrive Image with jsp</title></head><body><img src="/jsp/red_rose2.gif" name="
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 - Ajax
how 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
J2me image display - Java Beginners
J2me 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 Image on JDesktopPane
Display 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
java image display - Java Beginners
java 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
jsp image problem - JSP-Servlet
jsp image problem  hi everyone, How to display multiple images from mysql database to jsp page. please help me
image in jsp - JSP-Servlet
image 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 using Toolkit.getImage()
Display Image using Toolkit.getImage()       This section illustrates you how to display the specified image using Toolkit.getImage() method. To display the image, put an image
display the generated image from byte array - Struts
display the generated image from byte array  how to create image from byte array using struts and display it in struts html.please give me the sample code
Displaying image using jsp and spring.
Displaying image using jsp and spring.  how to display an image stored in WEB-INF/images folder on the browser using jsp and spring
Display image in the applet
Display image in the applet   ... illustrates you to display image in an applet which has been done in this example... and it's properties have been used to display the image in an applet. In this program only
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
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
Image preview - JSP-Servlet
Image 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
Jsp Image prob - JSP-Servlet
Jsp 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
Uploading image using jsp
; Here is a jsp code that upload image and display it on the browser. 1...Uploading image using jsp  how to upload image using jsp. Already i tried, But that image file does not read. It returns only -1 without reading
insert image - JSP-Servlet
insert image  hi friends i am mahesh i am trying to insert image into oracle database using JSP but i am not geting so please friends send me the code for inserting image into database using JSP   Hi Friend, Try
Retrieve Image in JSF From MySQL Table Using NetBeans IDE
to retrieve image and data from MySQL table using NetBeans IDE. In this application we create a jsp page to display image. In this JSP page we are using <h... .style1 { margin-right: 0px; } Retrieve Image in JSF From MySQL
dynamic display - JSP-Servlet
dynamic display  hi, i want to display dynamic values in drop drown box in a jsp page.these values are in the form of arraylist's object which... javax.servlet.http.*; public class DataServlet extends HttpServlet{ String page="/jsp
 

 

 

DMCA.com