I have three pages as shown in the code below. The header.html is included as part of summary.jsp and it appears at the top of the page of summary.jsp at run time.
When the user clicks on the logout link(located at the top of the portion of the summary.jsp page) I want to alert the user whether or not they really want to logout without approving the contents of the summary.jsp ( contents not shown on this page for simplycity).
I was expecting that pageName captured by the href link code shown under header.html gets passed to logout.jsp but I see null value instead of value of "lcSum". Please give me some idea why I am seeing null value of pName in logout.jsp page.
I also tried the following approach:
I get compilation error saying that value should be in quotes. I tried using = sign as shown below, but still get the same error.
I hope to hear from experts of this great java ranch website which has been very helpfull to me. Besides that unlike other websites I get quick and prompt response/solution on this java ranch.
Actually I had left out logout between anchor tags. In the actual code it is there. Anchor tag syntax looks right. Please let me know if the syntax is not correct.
Once again this is what I tried. I still get null value in logout.jsp.
What makes you think the JavaScript in your "href" attribute is executing? I suggested fixing it for a reason, and *looking* at the request being made for a reason.
I tried code shown below. It does pick up the value as shown in URL and does prompt OK. But logout.jsp does not get executed and instead I see Page Not Found Message.
.
I also tried the code without javascript as shown in the code block. I do see logout.jsp page displayed with URL shown in the code block but I do not see the value being passed to logout.jsp.
As far the other approach, whether we use single quote or double quote the compilation error is still the same.
I am more compfortable doing server side programming and JDBC programming than presentation tier programming. In my job I have to do all of these. I am learning presentaion tier side programming. My pages aren't pretty.
I will read about URL escape thing and will try your other suggestion of using JSP EL in the java bean approach. As I said before use of single quotes instead of double quotes as suggested by Tom Reilly does not make the difference(still get same compilation error)
1. JSP expressions should NOT end with a semicolon!
You must use double quotes for the pageName String in the expression because it has to be valid Java code (single quotes won't work).
2. Try removing the spaces from the URL:
3. If your application uses sessions, you should use the response.encodeURL() method with your links. Otherwise, clients who do not support cookies will not be able to use your site.
The trouble with your code is that part of the URL is generated using Javascript, which causes problems with this...
4. You should use EL and JSTL instead of scriptlets...scriptlets are bad practice.
Thanks for your guidance. The numbers shown below corresponds to your number.
1. JSP expressions should NOT end with a semicolon!
I tried without the semicolon but still get the same compilation error.
2. Try removing the spaces from the URL:
You are right, removing spaces in the URL works. I was able to see the value TEST in the logout.jsp
3. If your application uses sessions, you should use the response.encodeURL() method with your links. Otherwise, clients who do not support cookies will not be able to use your site.
I am using Request scope (not session). I will keep in mind your point in case I chose to use sessions.
4. You should use EL and JSTL instead of scriptlets...scriptlets are bad practice.
I tried the code shown by you under this and I get the message shown below. I think that is because when I installed Oracle JDeveloper tool I did not select JSTL.
5. Lastly, I tried the code in the code block removing spaces as suggested by you. The problem of "The webpage cannot be found" still persist. This confirms your thinking that the Javascript in that URL causing the problem of not displaying logout.jsp page.
The question is how to make the code in #5 and/or # 1 above to work. I am using code #1 to pass the pageName value to logoutBean where I can check its value and disconnect the database (JDBC) connection depending on user response to the prompt - 'Are you sure you want to logout without approving'.
(And it gets even worse once pages are made up of components, and your JSPs live in a more reasonable place (under /WEB-INF) and are never accessed directly.
I am using Jdeveloper to develop the application with default OC4J server. During the development when I create a JSP or HTML it automcatically puts it in the dirctory shown in the code block
The only file that goes into WEB-INF is the web.xml.
But When I create WAR file using Jdeveloper and I deploy WAR file on to TOMCAT server running on C drive. All *.jsp and *.html goes into the TOMCAT directory path shown below.
One other point is that I tried running just the header.html (by itself-outside of summary.jsp) but I still see the same message "The webpage cannot be found" message. "
Thanks,
Prabhakar
Michael,
I tested the setProperty code you suggested I still get the "The webpage cannot be found" message." Without the execution of logout.jsp page the code in the code block below will not be executed.
I think once we get the logout.jsp page to display everything else will go smooth. Your thinking that javascript is causing the problem is still correct.
Shown below is the OC4J log when I click on "logout' link. Just a note that I was seeing this same log content before as well.
David/Michael,
Please let me know your answers to the following questions:
1. Is there any other way (other than use of javascript) we can assign value of variable pageName in that href link?
2. I don't know much about CSS, can it be used to assign value to the pageName in that href link?
3. Is there any other way we can let logoutBean know user is trying to logout?
3. What if I use header.jsp instead of header.html? will it solve the problem?
Kaverappa Prabhkar wrote:1. Is there any other way (other than use of javascript) we can assign value of variable pageName in that href link?
I thought pageName cam from a textbox, but looking again I see that it doesn't. You don't have to use Javascript to build the link because its value isn't entered on the client-side by the user. Use a include standard action instead of an include directive and pass the pageName via a parameter. You have to turn header.html into a JSP:
Kaverappa Prabhkar wrote:2. I don't know much about CSS, can it be used to assign value to the pageName in that href link?
No
Kaverappa Prabhkar wrote:3. What if I use header.jsp instead of header.html? will it solve the problem?
See above.
Post by:autobot
We don't have time to be charming! Quick, read this tiny ad:
a bit of art, as a gift, the permaculture playing cards