This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
Sometimes, when you find something difficult to do it's because it wasn't meant to be done that way.
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
Thanks so much every one for your valuable replies.
@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.
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.
Sorry if that reference to your work made you wince there, Bill. Was just trying to impress the greenhorn there. Hey, if I ever get you to autograph my copy (which BTW, I still have sitting on the bottom of my "current" bookshelf; maybe it's time to retire it to the basement shelf with my Clipper and AS/400 RPG books) ... but I digress. Anyway, if I ever get you to autograph my copy of your book, it might actually be worth something some day.
@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.
@Junilu and Bill: Thanks for your reply. I will make use of those materials for my further studies.
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.
Durga, that "somebody" who will provide the solution is going to be you. These forums are not meant for finding people who will do your work for you. There are websites like that out there but this is not one of them. Please read some of the things that have already been suggested and give your best effort to try to solve the problem yourself. Thanks for your cooperation.
@Junilu : Really i didn't meant in that way. If my words were wrong i beg your pardon.
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.
Author and all-around good cowpoke
Joined: Mar 22, 2000
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.
@Brogden: Thanks for your reply. By the way, what i tried was to pass the selected values from child page to parent window, while clicking submit button. Please check my code snippets and provide me some suggestion.
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.
Author and all-around good cowpoke
Joined: Mar 22, 2000
What does "Parent Page" mean here?
Do you want to generate a whole new HTML page to replace an existing one?
Could anyone please suggest me the way of doing this?