This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HTML display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HTML display" Watch "HTML display" New topic
Author

HTML display

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Hi!

I am trying to run an application to test cookies.
Now for some reason it's not displaying form.html located in the application folder "CookyTest" .
It was working fine initially when I did not have it linked to any servlets but now i keep getting "Resource Not Found".

I am typing http://localhost:8080/CookyTest/form.html into the browser.

Can any one suggest me what else I can check.

i have checked spelling mistakes and my Tom cat is working...Any other suggestions are welcome ! Thanks!


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1700
    
  25

How does your web-application look like (structure of the war)?

Regards,
Frits
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Thanks Frits. Had some problem with the <url-pattern> , which is why it wasn't working

However i do have a question.

These are my two servlets

CookieTest.java





And CheckCookie.java





And I am getting the out put :

helloNabila Maximum age is -1
Path is null
Domain is null
Version is 0

CookieTest forwards to a jsp which then passes on to the CheckCookie.


I am just wondering why I am getting the max age as -1 and not as 30*60 , the way i set it initially.....
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

Hi Nabila,

(sorry Frits for hijacking)

If I read this right, you add a cookie to your response...do a few forwards and read it from the request ?
Well it hasn't been to a browser yet or anything, so nobody put it on your request. So you wont get it if you read it of course..


grtz Mark


I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
hmm.. I am getting a lil confused ...but I think I am getting your point....
So how would i modify the code to make it work...
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

Instead of forwarding, surf to your first page CookieTest (make it doGet instead of doPost). This will add the cookie to the response and send it to the browser.
Then surf to your CheckCookie page to view your cookie.

Notice that the browser received the cookie from the response of CookieTest, and will send it in the new request to CheckCookie
So CheckCookie will receive a cookie then.

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
I changed the doPost to doGet and now i am getting "HTTP method POST is not supported by this URL" even though i changed the form method to Get in the html file.

Anyway , what i was wondering was when you mentioned about surfing to a different Servlet ie. CheckCookie , did you mean using response.sendRedirect(.....) or is there a different way...?
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

I changed the doPost to doGet and now i am getting "HTTP method POST is not supported by this URL" even though i changed the form method to Get in the html file.


Perhaps the web page is still in your cache, try a control F5

Also, use firefox, and install firebug. Its an incredible help and web development without is is 100 times harder.
you can see what the browser sends over the wire for example.


is there a different way...?

you could simply surf to it , but a sendRedirect will also work since that does the same but without user interaction.

Are you reading HFSJ ?
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Let me give it a try again..

Yep I am reading HFSJ.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML display