• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to get the desired result as Hello UserName

 
Ranch Hand
Posts: 151
1
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following is the code











I am able to compile the code but not able to get the desired result. It should give me the "HELLO <USERNAME>" but it is not.

Kindly help me with this. Thanks in advance
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is it giving you?
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It gives an error 404 related to checkcookie.do.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's important information that you should include at the beginning.

Have you worked through the suggestions in the ServletsFaq for this issue?
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not include it as it runs first but at the end instead of giving the result gives the error.

Do I still need to check the FAQs?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, there is an entry with a checklist to go through when getting 404 errors.

Assume that you always should check the ServletsFaq before posting to check if your question has already been answered.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I went through the FAQs but it did not resolve the issue I am facing. I am sorry.

I could not find anything in the logs.

Could you please help?


 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, what have you changed as a result of going through the list? I see at least two errors that list should have helped you find.
 
Abhimanyu Jain
Ranch Hand
Posts: 151
1
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put the servlet classes in package after going through the list.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Two things:
  • This is a page-relative url; bad news. Be sure to use server-relative urls that start with the context path. See the JspFaq for more info.
  • Where is checkcookie.do mapped?
  •  
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I will go through JSPFAQs but how do I map checkcookie.do.

    I was thinking about it but could find a clue how to map it.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Do you understand the contents of the web.xml file?
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Oh! I got it. Thanks!
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I configured web.xml as follows but it did not work. Following is the file



    How do I configure "checkcookie.do" in DD? This is not the right way for sure otherwise it would have worked.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I thought you said you put the servlets into a package?
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I put it in package on Eclipse IDE. But first I am trying to sort it out manually where the servlets are not in package.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Servlets must be in a package. And that must be reflected in your web.xml. That's one of the items on the list.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It worked!!

    Following is the code from the Eclipse IDE for web.xml



    Thanks again!!
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Could you please help me with encodeURL as well, following is the code but it is not working as it should



    It shows a blank page after hitting the submit button instead of adding a jsessionid to the URL and showing the result.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    What is the path to cookieresult.jsp?
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    cookieresult.jsp is at the root of the application with login.html
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    How is the method to know that when you have provided no path? Hint: try a leading /.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I already tried it but it did not work. I disabled cookies in all the browsers I have (Chrome, IE and Firefox) but same result all the time.

    So what's the next step now?

    Thanks in advance

     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I just noticed this: why are you calling encodeURL for a forward? Don't do that.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    OK. Then how do I call encodeURL? I replaced RequestDispatcher with encodeURL but it did not work.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I already told you: don't call encodeURL. It's not for use with forwards.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    OK. But then how do I see JSESSIONID appended to the URL. I wish to use the method "encodeURL()" so I could understand how it works and when to use it.

    Please help!!
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You only use it with redirects; not with forwards.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I tried but it did not work. I have no clue now. But I want to fix it somehow.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    ItDoesntWorkIsUseless
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I didn't get you I am sorry. Should I leave it now?
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Read the link I posted. It's a link to a FAQ article.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I am really sorry.

    Following is the code I changed it to:-

     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You either need to do a forward or a redirect. Right now, you're not doing either so of course nothing will happen.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I changed the code but still it shows a blank page



    I thought I could use "encodeURL()" after disabling the cookies on the browser as "encodeURL()" adds "jsessionid" at the end of the URL if the cookies are disabled.
     
    Marshal
    Posts: 28177
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Bear Bibeault wrote:You either need to do a forward or a redirect. Right now, you're not doing either so of course nothing will happen.



    This statement is still true about the code you just posted.
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    But I am using redirect now as told
     
    Abhimanyu Jain
    Ranch Hand
    Posts: 151
    1
    Eclipse IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Now I changed it to the following but still nothing

     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Your redirect URL is page-relative. Bad idea. For a redirect you need to use a server-relative URL if the path is on the same server, or an absolute path if on a different server.

    Look at it from the point of view of the container: with the scant information you've given it -- just a page name -- how is it supped to find it? It's like saying "Where does Ralph live?" with the answer "In a blue house". Good luck finding Ralph.

     
    reply
      Bookmark Topic Watch Topic
    • New Topic