wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Trouble with application attribute / jspInit... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Trouble with application attribute / jspInit..." Watch "Trouble with application attribute / jspInit..." New topic
Author

Trouble with application attribute / jspInit...

Roger Yates
Ranch Hand

Joined: Aug 31, 2004
Posts: 118
I'm following HFS (p308) and attempted to rustle up a quick test of the code snippet to test servlet init parameters and overiding jspInit. But instead of the email address appearing, I'm getting the following output:

Please email: null

What am I doing wrong?!

My .jsp file (TestInit.jsp) is as follows:


and my web.xml (located in WEB-INF!) is:


I put a servlet-mapping in because I wanted to see if jsp's could be mapped as well, but this doesn't seem to work either (successfully mapped a servlet in earlier chapters!).

So, two questions:
1. Why am I not seeing the email address produced by my jsp?
2. Can you map jsp's to url-patterns?

Any help appreciated!
And, yes,I've stop/started tomcat many times and even changed the .jsp to prove it's the active one!
Symptom-wise it seems that the init value is not being picked up, but web.xml is correctly in WEB-INF so I see no reason why this doesn't work!

To invoke it, I am using:

Help!
Thanks,
Roger


Cheers,<br />Roger<br />SCJP 1.2, 1.4, SCBCD 1.3, SCWCD 1.4
Roger Yates
Ranch Hand

Joined: Aug 31, 2004
Posts: 118
OK, my mistake!
1. Output now correct.
2. servlet-mapping, url-pattern now working for jsp.

My first problem was invoking the .jsp direct. This seems to bypass the use of the DD, hence "email" never gets initialised.

I'd used direct invocation of .jsp because I thought I was having problems using servlet-mapping for this jsp. It turned out that servlet-mapping was occurring, but no params were being initialised.
The reason? Because at the time I had left out the "xlmns" bits & pieces (technical term) at the start of the DD.
Somewhere along the line, although I had added the namespaces, I never retried the servlet-mapped address having done so. I was still invoking the .jsp directly. :roll:

Having finally retried again using "http://localhost:8080/testJsp/myInit.do" I get the correct output:
"Please email: somewhatfrustrated@trying.com"


Roger
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Thanks so much for posting what you figured out Roger!!

That helps everyone.

cheers and thanks for having the patience to keep trying,
Kathy
 
jQuery in Action, 2nd edition
 
subject: Trouble with application attribute / jspInit...