I am a beginner to JSP. I am developing a small dynamic web project. In that i am haivng 2 JSP's. 1 is Main.jsp & other is Action.jsp. In Main.jsp(Parent Window) ,am having a check box. On clicking it, it should open Action.jsp(Chile Window). While loading i want some values to be read from the property file & those contents should be displayed in pop-up window(Action.JSP). I am feel difficulty in this. My property file is an text file haivng some static values like A,B,C. How to read the values from property file?
P.S: I am having the propery file in the same location where am having the JSP files.
Please help me in this.
Thanks in advance!
On anything other than a toy or throw-away application, that is, if you're developing a web application that will be maintained and/or extended over a period of time, you should separate display concerns from concerns related to infrastructure and business logic. Reading from a properties file is an infrastructure/configuration concern. JSPs should be concerned mainly with presentation. They would display information that is already available in the current context. Don't make the JSP responsible for retrieving the values from the properties file. Otherwise, you'll be mixing two distinctly separate responsibilities and there are good reasons for not doing that (maintainability and cohesion, for instance).
It's the same reason you normally don't ask the makeup person on a movie set to go and set up the tracks for the camera dolly -- that would be chaotic, not to mention against union rules
Stefan Evans wrote:It could be noted that the Properties class does implement the Map interface, and you can pass it straight back to your JSP for read-only purposes.
Huh, I didn't even realize that but now that you mention it, it makes perfect sense. Shows you how much I ever even bother with properties files. Thanks, Stefan.
@Junilu Lacar: Thanks for pointing my mistake gently, as iam the beginner of JSP iam not aware of this. Let me know about JSP more in depth now onwards. If you can please suggest any material and links for me to start my JSP reads.
Thanks to stefan & everyone for the reply.
Thanks in advance.
Durga Kannan wrote:@Junilu Lacar: Thanks for pointing my mistake gently, as iam the beginner of JSP iam not aware of this. Let me know about JSP more in depth now onwards. If you can please suggest any material and links for me to start my JSP reads.
I would be remiss if I didn't tell you that William Brogden, one of our all-around good cowpokes and ranchers you've seen in this very thread, has a book of exactly that nature. Also search for articles about Model 2 JSPs (as opposed to Model 1 JSPs), such as this old but still pretty helpful standby from JavaWorld.
@Durga: In all seriousness, I'm flipping through Bill's old book here and there are still some basic things about JSPs that you can find useful. However, so you don't get confused by some of the older material mixed in there, you'd probably be better served by getting a more recent book about Servlets and JSPs, as Bill suggests.
Now am having a new doubt: This is my current scenario:
I am having the Main.jsp & Action.jsp (As i specified in my older posts). In Action.jsp, am doing some normal selection operation from selection box[e.g A,B] & this result should be passed to back and it should display in the check box present in main page on clicking submit(in action page). How should this be implemented?
These are my tries: I wrote a function cal in the submit button. In that function, am having session.set attribute. So that i can use the get attribute in the main page,to get the value. But am unable to do this.
Could somebody please provide solution for this?
1)In child page Selection should be made.
2)The selected result should display on parent window.
I am trying some trial and error methods for getting the solution. Mean while i need to get some valuable suggestion. I thought here i would get it. So only i explained my difficulty in my last post. Really sorry and i will try my own ways to get the value passes from one page to other.
And i didn't ask other people to do work for me ever. As iam a new comer to JSP, things are new to me. That's the reason i asked like "could somebdy provide solution" rather asking suggestion.
Sorry and thanks for your reply.
Don't worry about it. We understand that English is not the primary language of many of our visitors. That's one of the reasons for our "be nice" policy. As moderators we have to balance niceness with firmness though. So the best way for you to get people to help you is to follow a format similar to this:
Confused About Something wrote:
Hello! I'm trying to figure out how to implement something like this: (describe exactly what you are trying to do here)
My problem is (describe what you're having difficulty with)
I'm not quite sure how to (whatever it is you're trying to do that's confusing or not working)
Here are some things I tried: (include some relevant code samples here)
(Here you can put your final plea for help or statement of gratitude in advance of help offered. Some examples follow:)
I really would appreciate any help or pointers on how to proceed
I am stumped at this point, any comments on how I can get past this?
Are there any concepts I'm not getting here? If so, any helpful tips or links would be greatly appreciated
You have actually followed most of this template except for the part about providing code samples of what you've tried. And of course, your "final plea" was worded in a way that can be easily misunderstood but that's Ok since you clarified that in your last post.
I wrote a function cal in the submit button. In that function, am having session.set attribute. So that i can use the get attribute in the main page,to get the value.
Thanks a ton!!!
Any help for transferring values from child to parent window would be greatly appreciated..
Thanks so much in advance.
//Code for my Child.JSP
Sorry for my long snippet. Thanks in advance for your kind help.
Yes, but i am trying to replace/generate new HTML page. Rather, am having parent page already, in which i want the seleced value from child page should display there.
Anyways i will see the Java script forums.
Thanks so much for your kind reply.
Could anyone please suggest me the way of doing this?