The fact that you need the name of the JSP is a red flag that you have a serious design problem. In fact, in a properly structured web application, the name of the JSP is abstracted away and there is no way to know what it is.
Why not let us know why you think you need this information and we can guide you to a better way of doing things.
Joined: Sep 10, 2008
I have a menu that I am building and putting in a tag file. I want to send the current page to the tag file so that the link to the current page in the menu is not active. In other words the link to the current page will not be active.
Using the page name as a trigger is a really bad and fragile design. A better approach would be to have an attribute on the tag that tells the tag which entry to disable. The calling pages can set this value as appropriate.
This is an example of loose coupling and is a good precedent to follow.
Something along those lines, yes. That way, the code isn't tied to the file name, which is (a) fragile, as everything breaks if the file name is changed, (b) difficult to deduce in a deterministic manner (there are way too many "what if" scenarios).
The fewer things that depend upon implicit dependencies (tight coupling) like filenames, the more robust and less fragile your code will be.
Joined: Nov 17, 2007
Please don't post if you don't know the answer to the question being asked. Your unsolicited design claim makes this thread useless. Bob's question is valid not to mention the fact that his approach is simpler and will require less maintenance in the future. In a small system this will work just fine. I suppose it would be appropriate for you to offer design advice as a footnote but only after you have answered the question correctly.
You're new here aren't you? Welcome to the Ranch! JavaRanch is a learning site, not an answer or code mill. If the posting of advice and best-practice recommendations offends you -- indeed, in a thread in which you did not even participate -- then you may be disappointed here. [ December 31, 2008: Message edited by: Bear Bibeault ]
Thank you for the warm welcome. I've used this resource for several years although I generally don't post(call me shy). After 19.5 years of dealing with developers like myself, I am comfortable with spirited interactions. I read the link you suggested concerning older topics however I still would have posted to this thread despite the fact that it is not in my nature to post. I felt compelled to contribute my perspective because I believe that there is a bigger topic here. I'd like to see JavaRanch continue to be "a friendly place for greenhorns". You may want to try a little role playing. Imagine yourself as Bob and have someone read to your thread contributions to you.