• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Unable to get the desired result as Hello UserName  RSS feed

 
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aside: why are you going directly to a JSP page rather than a controller? Poor practice. Please read this article.
 
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed the



to



But still I get the same result as a blank page.

Could you please suggest where I am doing it wrong? Thanks!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does http://localhost:9090/SessionCheck/cookieresult.jsp display when typed directly into the browser?
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Click Here" link and when the link is clicked nothing happens a blank page comes up. It should show "Hello <User Name>" and in the URL "jsessionid" should be appended in the end.

It happens when the cookies are disabled once cookies are enabled it displays the user name with hello.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will not give up until I fix it as it will clear my doubts about encodeURL and how it works to some extent.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Until the page is working when you directly address it in the browser, it makes no sense to try to redirect to it. If the page isn't working, the page needs to be fixed.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the page works when the cookies are enabled it shows the result but when the cookies are disabled or blocked on the browser it gives nothing. I tried three browsers.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I am getting following error

HTTP Status 404 - /checkcookie.do

type Status report

message /checkcookie.do

description The requested resource is not available.
Apache Tomcat/7.0.59

Please help!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IS the URL correct? Did you change the mapping in web.xml?
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I did not change anything in web.xml file. I just restarted the system.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your URL correct?
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is correct. I checked it again. It gives "Click Here".
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the "click here"? A link on a page? If so, what's generating it? What's the URL of the link?
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is a link to a page which should generate "HELLO <User Name>". URL of the link is "http://localhost:9090/checkcookie.do" as shown in the address bar.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your URL is missing the context path.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how do I add the context to it? Isn't it the path generated by web.xml?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The context path must be part of the URL. How is the container supposed to know which web app (context) to send the request to without it?

See the JspFaq for how to create links with the context path.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added the context path but still the same blank page I am getting. Following is the complete code











Kindly check it and help me fixing it. I will be really grateful to you!!

I want to add jsessionid at the end of the URL when the cookies are disabled on the browser. I will be grateful. Thanks!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the http://localhost:9888/SessionCheck/cookieresult.jsp link work when typed into the browser?
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it works. It gives another link "Click Here".
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which link is failing? You do not write very precise posts so it's hard to answer your questions. Please tell us exactly, and in detail, what is happening.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry for incomplete information.

All I am trying to do is, block the cookies and use "encodeURL()" method to append "jsessionid" at the end of the URL.

The URL that must show the "jsessionid" appended to it, is "http://localhost:9888/SessionCheck/checkcookie.do" but it does not show it.

I have added the context to the URL as suggested by you. I disable the cookies on the browsers like chorme, firefox and IE but it does not show "jsessionid" due to some reason.

I read if the browser does not accept the cookies, the "jsessionid" is appended to the URL if we use "encodeURL()" so I want to test the same.

I run application using "http://localhost:9888/SessionCheck/login.html", I click the "Submit" after entering the name, a new link "Click Here" comes up, I click it and a blank page comes up instead of "Hello <Name>" and the "jsessionid" appended to the URL (http://localhost:9888/SessionCheck/checkcookie.do).

Kindly let me know if this helps!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's confusing is that you have two URLs -- the one you a redirecting to and the one that's the href of the "click here" link. Which are you trying to affect?

Have you tried logging the result of encoding the url in the servlet? If not, why not? Apply normal debugging techniques.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed it. Following line was missing from the servlet:



Thank you for the support!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!