File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Hyperlinks Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Hyperlinks" Watch "Hyperlinks" New topic
Author

Hyperlinks

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
I am working on my first web application - Photo Album. I have a JSP page that retrieves an image from each album. The client can then click on this to take them to the rest of the photos in that album. However, I am pretty sure that the hyperlink should be something like "http://localhost/examples/albums/album1" but I dont understand how this should be passed to my other jsp Page displayAlbum.jsp to determine which album it should display.
Thanks in advance.
Debashish Chakrabarty
Ranch Hand

Joined: May 14, 2002
Posts: 224

David:
You may pass the member name or unique id for the member or album through
  • query string
  • If there is a midlying page you may pass the value inside a hidden form field

  • With query string your URL will look something like http://localhost/examples/jsp/displayAlbum.jsp?album=album1. To dynamically generate this hyperlink however you will have to add the query string for eg.
    Talking of your album page however you can generate the hyperlinks dynamically in the JSP itself (which is displaying all images and where the user would click to view his album). So the hyperlink for image 1 would be, say, http://localhost/examples/jsp/displayAlbum.jsp?album=album1 and so on.
    Did it help? Do get back..
    [ February 13, 2003: Message edited by: Debashish Chakrabarty ]

    Debashish
    SCJP2, SCWCD 1.4
    david allen
    Ranch Hand

    Joined: Sep 27, 2002
    Posts: 185
    Hi Debashish,
    Thank you very much for that. I now have it working and can easily associate the album name with each album link. It is much easier than I thought.
    One other question. The hyperlink being "http://localhost/examples/jsp/displayAlbum.jsp?album=album000"
    What happens if I change the name of the server or servers. Is there some function that can get the server name so for example hyperlink = getServerName() + /examples/jsp/displayAlbum.jsp?album=album000"
    thanks for your help
    david
    Debashish Chakrabarty
    Ranch Hand

    Joined: May 14, 2002
    Posts: 224

    You would not normally write the absolute URL in such cases. Since you would be aware where your JSPs are (eg.in the present case while you are testing the JSPs on your own machine and know that all of them are in examples/jsp directory of your webserver directory), all your URLs would be app relative URLs for eg:

    The URL specified is normally interpreted relative to the JSP page that refers to it, but, as with relative URLs in general, you can tell the system to interpret the URL relative to the home directory of the Web server by starting the URL with a forward slash.
    Regards
    [ February 14, 2003: Message edited by: Debashish Chakrabarty ]
     
    IntelliJ Java IDE
     
    subject: Hyperlinks
     
    Threads others viewed
    Testing File to see if it Exists, and writing meta data
    sending a servlet parameters
    Checking to see if my session has expired
    jsp-servlts erro
    Photo Album in JSP
    IntelliJ Java IDE

    cast iron skillet 49er

    more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture