Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Retrieving image paths from XML file

    Hello,
    I'd like to retrieve texts and image paths from an XML file. The data shall be parsed and then saved in a bean object. It's no problem to display the text from every dataset, but I don't know how to fetch the image path from the bean and then display the image in the JPS.
    Any ideas how this could work?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: Retrieving image paths from XML file

    So what bits have you done?

    For the displaying of the image, you'll need to use an <img> tag with a reference to a servlet that will return the relevant image, based on some identifier.
    You cannot simply pass the image to the client along with the rest of the page.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: Retrieving image paths from XML file

    Actually, that assumes the path is not accessible by the client.
    If the path is to an image that is accessible (ie it's part of the website root folder, or non-WEB-INF sub-folder) then you could simply put the path into the <img> tag.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Retrieving image paths from XML file

    I still don't understand how this works. I have a jsp page with 3 buttons. Depending on which button has been clicked, some text and an image shall be loaded. The text and the image file paths are located in the XML file.

    The jsp calls the Controller servlet with this code:
    XML Code:
    <form action="Controller" method="get">
    	        <input type="submit" value="btn 1" name="btn1"/>
    		<input type="submit" value="btn 2" name="btn2"/>
    		<input type="submit" value="btn 3" name="btn3"/>		
    	</form>
    The Controller servlet then decides which data to load:
    Java Code:
    protected void doGet(HttpServletRequest request,
    			HttpServletResponse response) throws ServletException, IOException {
    		
    		String target = "index.jsp";
    		
    		if (request.getParameter("btn1") != null) {
    			.......
    		} else if (request.getParameter("btn2") != null) {
    			.......
    		} else {
    			.......
    		}
    		
    		RequestDispatcher dis = request.getRequestDispatcher(target);
    	       dis.forward(request, response);
    Last edited by noodle_variation_187-X; 06-08-2012 at 03:35 PM.

Similar Threads

  1. retrieving/uploading image
    By stegano in forum New To Java
    Replies: 6
    Last Post: 04-07-2011, 03:56 AM
  2. Replies: 3
    Last Post: 11-11-2010, 10:22 AM
  3. JAR file paths
    By atholon in forum New To Java
    Replies: 6
    Last Post: 05-03-2010, 01:03 AM
  4. Retrieving image stored as BLOB object in oracle
    By venkateshcoolmoon in forum JDBC
    Replies: 11
    Last Post: 01-17-2010, 06:06 PM
  5. a little help with file paths
    By ashton in forum New To Java
    Replies: 3
    Last Post: 01-27-2009, 04:08 PM

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
  •