Results 1 to 5 of 5

Thread: Images Upload

  1. #1
    ayesh is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default Images Upload

    hi guys
    I created an upload jsp for uploading images, the images get uploaded successfully and, I store them in dynamically created directorys not in the database.

    The Problem is:
    I need these images to be deployed to the web container, I didn't realize I'm gonna face this problem before,
    if I make an <img src="uploaded/newImage.jpg"></img>
    it is useless !!!
    plz any body have an idea....

  2. #2
    baloda is offline Member
    Join Date
    Nov 2010
    Location
    New Delhi
    Posts
    50
    Rep Power
    0

    Default

    use this code

    <%String s=request.getContextPath() + "/abc.JPG";%>
    <img src="<%=s%>" width = "500" hight = "600" aligh = "center" />

    an example is here

    Create chart and Display them dynamically in JSP: Uploading Image in jsp, java, Netbeans

  3. #3
    pranutanu is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Default

    hiiii we have created a login page using html and servlets. we hav created a database in ms access to access the username & password.When username and password is entered it should link to the html home page this has been done successfully but the images is not displayed. there is some linking problem but we dont know what? plz tell us the whole procedure to link images. the code is as follows.

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    public class Login extends HttpServlet
    {
    public void doGet (HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException
    {
    res.setContentType("text/html");
    PrintWriter out=res.getWriter();
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch(ClassNotFoundException e1)
    {
    System.out.println(e1);
    }
    try
    {
    Connection con=DriverManager.getConnection("Jdbc:Odbc:mydsn") ;
    int flag=0,flag1=0;
    String x=req.getParameter("t1").trim();
    String y=req.getParameter("t2").trim();
    Statement st=con.createStatement();
    ResultSet rs1=st.executeQuery("select * from login");
    while(rs1.next())
    {
    String s=rs1.getString("username");
    if(s.equals(x))
    flag=1;
    }
    if(flag==1)
    {
    PreparedStatement pst=con.prepareStatement("select password from login where username=?");
    pst.setString(1,x);
    ResultSet rs2=pst.executeQuery();
    while(rs2.next())
    {
    if((rs2.getString("password")).equals(y))
    flag1=1;
    }
    if(flag1==1)
    {
    res.setContentType("text/html");
    out.println("<html>");
    out.println("<head>");
    out.println("<title>welcome to beauty salon</title>");
    out.println("</head>");
    out.println("<body bgcolor=\"white\">");
    out.println("<table bgcolor=\"#a40379\" cellspacing=4 cellpadding=4 width=1000bgColor=\"#101EE5\"align=\"center\" border=3>");
    out.println("<tbody bgcolor=\"#ffffff\"> <tr valign=top border=2 bgcolor=\"#ffffff\">");
    out.println(" <td >");
    out.println("<img src=\"../images/banner2.jpeg\" width=\"1000\" height=\"250\">");
    out.println("</td>");
    out.println("</tr>");
    out.println("<tr>");
    out.println("<td>");
    out.println("<table width=\"700\" height=\"50\"bgcolor=\"#760756\"cellspacing=3 cellpadding=3 border=2 align=center valign=top>");
    out.println("<tr>");
    out.println("<td align=middle width=200 height=50 bgcolor=\"#ab5fab\" >");
    out.println("<b>");
    out.println("<a href =\"../bg45.html\">");
    out.println("<font color=\"#000000\" size=3>Service Provided</font>");
    out.println("</a></b></td>");
    out.println("<td align=middle width=200 height=50 bgcolor=\"#ab5fab\" >");
    out.println("<b><a href =\"../bg45.html\">");
    out.println("<font color=\"#000000\" size=3>Service charge sheet</font>");
    out.println("</a></b></td>");
    out.println("<td align=middle width=200 height=50 bgcolor=\"#ab5fab\" >");
    out.println("<b><a href =\"../bg45.html\">");
    out.println("<font color=\"#000000\"size=3>Accounting</font>");
    out.println("</a></b></td>");
    out.println("<td align=middle width=200 height=50 bgcolor=\"#ab5fab\" >");
    out.println("<b><a href =\"../bg45.html\">");
    out.println("<font color=\"#000000\"size=3>Bill</font>");
    out.println("</a></b></td></tr>");
    out.println("</table>");
    out.println("</td>");
    out.println("</tr>");
    out.println("<tr>");
    out.println("<td>");
    out.println("<table cellspacing=3 cellpadding=3 bgcolor=\"#760756\" border=2 valign=\"middle\" align=\"left\" >");
    out.println("<tr>");
    out.println("<td align=middle width=200 height=50 bgcolor=\"#ab5fab\" >");
    out.println("<b><a href=\"../contacts.html\">");
    out.println("<font color=\"#000000\"size=4>Contacts</font>");
    out.println("</a></b></td>");
    out.println("</tr>");
    out.println("<tr>");
    out.println("<td align=middle bgcolor=\"#ab5fab\">");
    out.println("<b><a href =\"../appointments.html\">");
    out.println("<font color=\"#000000\" size=4>Appointments</font></a></b></p></td>");
    out.println("</tr>");
    out.println("<tr>");
    out.println("<td align=middle width=200 height=50 bgcolor=\"#ab5fab\">");
    out.println("<b><a href =\"../income.html\">");
    out.println("<font color=\"#000000\"size=4>Daily Income</font></a></b></p></td>");
    out.println("</tr>");
    out.println("<td align=middle width=200 height=50 bgcolor=\"#ab5fab\">");
    out.println("<b><a href =\"../maintance.html\">");
    out.println("<font color=\"#000000\"size=4>Maintance</font></a></b></p></td>");
    out.println("</tr>");
    out.println("</table>");
    out.println("<h3><i><span style=background-color:\"#00000\"> <font face=\"Arail blackman\" color=#000000>");
    out.println("<b> About Us</b></i></h3>");
    out.println("</font></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp; ");
    out.println("<font face=\"times new roman\" color=\"#2712A1\" size=5><b>A beauty salon or beauty parlour (or sometimes beauty shop)is an establishment dealing with cosmetic treatments for men and women.");
    out.println(" Other variations of this type of business include hair salons and spas. ");
    out.println(" <br>");
    out.println(" There is a distinction between a beauty salon and a hair salon and " );
    out.println(" although many small businesses do offer both sets of treatments beauty" );
    out.println("salons provide more generalized services related to skin health, facial " );
    out.println("aesthetic, foot care, aromatherapy, even Bridal Makeup, Oxygen therapy, High frequency ");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" );
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp; therapy and innumerable other services." );
    out.println("</b></font><br></td></tr>");
    out.println("<tr>");
    out.println("<td>");
    out.println("<marquee valign=\"bottom\" behavior=\"scroll\" scrollamount=\"10\" scrolldelay=\"100\" bgcolor=\"#ab5fab\" height=\"14%\" width=\"1000\" border=\"3\" color=\"#FFFFFF\">");
    out.println("<a href=\"../Login.html\">");
    out.println("<img height=\"150\" src=\"../images/bridalmakeup.jpg\"width=\"150\">");
    out.println("<img height=\"150\"src=\"../images/layered-hairstyle.jpg\" width=\"150\">");
    out.println("<img height=\"150\" src=\"../beauty/ff.jpg\" width=\"150\">");
    out.println("<img height=\"150\" src=\"../images/ee.jpg\" width=\"150\">");
    out.println("<img height=\"150\" src=\"../images/www.jpg\" width=\"150\">");
    out.println("<img height=\"150\" src=\"../beauty/mani.jpg\" width=\"150\">");
    out.println("<img height=\"150\" src=\"../beauty/pak.jpg\" width=\"150\">");
    out.println("<img height=\"150\" src=\"../beauty/p.jpg\" width=\"150\">");
    out.println("<img height=\"150\" src=\"../beauty/mehandifeet.jpg\" width=\"150\">");
    out.println("</marquee></td></tr>");
    out.println("</table>");
    out.println("<center>");
    out.println("<h4> <font face=\"Arail black\"color=#000000align=\"middle\">");
    out.println("<b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp; ");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<font face=\"Arail black\"color=#ED273E align=\"middle\" size=5><u>Contact Us");
    out.println("</u></font>");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;");
    out.println("<br>");
    out.println("<img height=\"50\" src=\"images/email_1.gif\" width=\"50\">");
    out.println("<u>Email Address</u>:- tanuja.rokade248@gmail.com&amp<br>");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp; ");
    out.println("pranali_waghmare08@rediffmail.com ");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;");
    out.println("<u>Phone No</u>:- 9209220172&nbsp &amp&nbsp7709603117&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<br>");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");out.pr intln("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;");
    out.println("</b></i></h4></font>");
    out.println("<font color=\"#FFFFFF\" font face=\"times new roman\" >");
    out.println("<marquee behavior=\"alternate\" style=\"#FFFFFF\">");
    out.println("<strong><h2><b>");
    out.println("<span style=background-color:\"#ED273E\">Thank You For Visiting. Keep Visiting");
    out.println("</span></b></h2></strong>");
    out.println(" </marquee>");
    out.println("</font></center>");
    out.println("</body></html>");
    }
    else
    {
    res.setContentType("text/html");
    out.println("you are invalid user");
    }
    out.close();
    }
    }
    catch(SQLException e2)
    {
    System.out.println(e2);
    }
    }

    }

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,442
    Rep Power
    18

    Default

    Please use code tags when posting code.

    Where are your images located?
    For example, this one:
    <img src=\"../images/banner2.jpeg\" width=\"1000\" height=\"250\">

    Also, you have waaaaay too much going on in there. You need to learn to break down your methods.
    Why not use a JSP page?
    Or even straight HTML, because (and it's hard to read) I can't see anything dynamic in there at all.

  5. #5
    baloda is offline Member
    Join Date
    Nov 2010
    Location
    New Delhi
    Posts
    50
    Rep Power
    0

    Default

    out.println("<img src=\"../images/banner2.jpeg\" width=\"1000\" height=\"250\">");

    instead of direct path use this code and u should place all images and servlet must be in the same folder.

    String s=request.getContextPath() + "/banner2.jpeg";
    out.println("<img src=" + s +width=\"1000\" height=\"250\">");

    good luck. and u should use jsp pages for this kind of things.

    http://java-sql.blogspot.com/2010/12/chart-in-java.html
    Last edited by baloda; 03-16-2011 at 05:25 AM.

Similar Threads

  1. JSP File Upload
    By maas in forum JavaServer Pages (JSP) and JSTL
    Replies: 6
    Last Post: 07-09-2010, 11:07 AM
  2. :large file upload to server(chunk upload)
    By tommy_725 in forum Networking
    Replies: 0
    Last Post: 10-16-2009, 12:21 AM
  3. xml upload very slow
    By sandeeprao.techno in forum Advanced Java
    Replies: 1
    Last Post: 06-10-2008, 06:24 AM
  4. File Upload
    By ShoeNinja in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 11-09-2007, 10:09 PM
  5. Rad Upload 3.12
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-01-2007, 06:50 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •