Registering Servlets
In the web.xml file I need to include init params Like this: init-param param-name passwordFile /param-name param-value C:\SANDRA\BC Transit\IDCardProject\Passwords\passwords.properties /param-value /init-param What I have done here, however, is wrong. Story of my life... I am creating a passwordFile using a FileOutputStream to the address above like this: String passwordFile = C:\\SANDRA\\BC Transit\\IDCardProject\\Passwords\\passwords.properties; FileOutputStream out = new FileOutputStream(passwordFile); However when I call it like this: passwordFile = config.getInitParameter(passwordFile); passwords = new Properties(); passwords.load(new FileInputStream(passwordFile)); The above web.xml does not do the trick. I believe my param-name is correct, but what should the value be? Sandra Patricia Hunter Systems Development and Web Design - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Registering Servlets
Sandra Patricia Hunter wrote: [...] I am creating a passwordFile using a FileOutputStream to the address above like this: String passwordFile = C:\\SANDRA\\BC Transit\\IDCardProject\\Passwords\\passwords.properties; FileOutputStream out = new FileOutputStream(passwordFile); However when I call it like this: passwordFile = config.getInitParameter(passwordFile); passwords = new Properties(); passwords.load(new FileInputStream(passwordFile)); The above web.xml does not do the trick. I believe my param-name is correct, but what should the value be? You have to stop and then start Tomcat when you want the web.xml to be re-read. Also, you didn't mention the error or problem you're getting? Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Registering Servlets
Hi Erik: This is my web.xml: servlet servlet-nameProtectedPage/servlet-name description this is the first menu for the application /description servlet-classidcard.ProtectedPage/servlet-class init-param param-name passwordFile /param-name param-value Passwords /param-value /init-param /servlet What happens is that when I enter what should be correct username/password pairs they are not recognized. The value above for the name passwordFile is not correct so I do not see the page as I should. Does that help? Sandra Patricia Hunter Systems Development and Web Design -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: March 27, 2003 10:43 AM To: Tomcat Users List Subject: Re: Registering Servlets Sandra Patricia Hunter wrote: [...] I am creating a passwordFile using a FileOutputStream to the address above like this:String passwordFile = C:\\SANDRA\\BC Transit\\IDCardProject\\Passwords\\passwords.properties; FileOutputStream out = new FileOutputStream(passwordFile); However when I call it like this: passwordFile = config.getInitParameter(passwordFile); passwords = new Properties(); passwords.load(new FileInputStream(passwordFile)); The above web.xml does not do the trick. I believe my param-name is correct, but what should the value be? You have to stop and then start Tomcat when you want the web.xml to be re-read. Also, you didn't mention the error or problem you're getting? Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Registering Servlets
Sandra Patricia Hunter wrote: What happens is that when I enter what should be correct username/password pairs they are not recognized. The value above for the name passwordFile is not correct so I do not see the page as I should. Does that help? Sort of. I mean, I understood the nature of the problem, but wasn't sure if you were getting an exception or compiler error. Are you sure that it's a matter of reading the init-param? I'd try printing out the value of that init-param from your servlet with code similar to this in doGet(): String name = passwordFile; String value = this.getServletConfig( ).getInitParameter(name); PrintWriter out = resp.getWriter(); out.println(h1The value of + name + is + value + /h1); This will tell you whether or not it's a problem with your web.xml file or if it's your bidness logic. Also, not sure if you fully stopped and started Tomcat... Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Registering Servlets
Well, it's printing out the value I assign in the web.xml file. Still it is not recognizing the user/password pairs. I think that I don't have the correct value but I don't know what correct would be? I am using the code from Marty Hall's core servlets book called protectedPage, and it should be straightforward but not. Sandra Patricia Hunter Systems Development and Web Design -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: March 27, 2003 11:05 AM To: Tomcat Users List Subject: Re: Registering Servlets Sandra Patricia Hunter wrote: What happens is that when I enter what should be correct username/password pairs they are not recognized. The value above for the name passwordFile is not correct so I do not see the page as I should. Does that help? Sort of. I mean, I understood the nature of the problem, but wasn't sure if you were getting an exception or compiler error. Are you sure that it's a matter of reading the init-param? I'd try printing out the value of that init-param from your servlet with code similar to this in doGet(): String name = passwordFile; String value = this.getServletConfig( ).getInitParameter(name); PrintWriter out = resp.getWriter(); out.println(h1The value of + name + is + value + /h1); This will tell you whether or not it's a problem with your web.xml file or if it's your bidness logic. Also, not sure if you fully stopped and started Tomcat... Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Registering Servlets
At 11:04 AM 3/27/2003, you wrote: Sandra Patricia Hunter wrote: What happens is that when I enter what should be correct username/password pairs they are not recognized. The value above for the name passwordFile is not correct so I do not see the page as I should. Does that help? Are you sure that it's a matter of reading the init-param? I'd try printing out the value of that init-param from your servlet with code similar to this in doGet(): String name = passwordFile; String value = this.getServletConfig( ).getInitParameter(name); PrintWriter out = resp.getWriter(); out.println(h1The value of + name + is + value + /h1); This will tell you whether or not it's a problem with your web.xml file or if it's your bidness logic. When dealing with pure java like you are here, it's generally a good idea to setup your file path names like this: C:/home/whatever/webapp/passwords.props instead of using the escaped slashes. Java will convert this to your OS-specific path separator *if* you are specifying a file that the JVM will load. I suspect that if you do what Erik suggested above, you'll find that your initparam is something like this: c:\home\whatever\webapp\passwords.props which, when given to the FileOutputStream, will result in a search for a file named: c:/ome/hatever/ebapp/asswords.props that (probably) ;) doesn't exist. justin Justin Ruthenbeck Software Engineer, NextEngine Inc. justinr - AT - nextengine DOT com Confidential See http://www.nextengine.com/confidentiality.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Registering Servlets
Sandra Patricia Hunter wrote: Well, it's printing out the value I assign in the web.xml file. Still it is not recognizing the user/password pairs. I think that I don't have the correct value but I don't know what correct would be? I am using the code from Marty Hall's core servlets book called protectedPage, and it should be straightforward but not. What chapter? Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Registering Servlets
Four Sandra Patricia Hunter Systems Development and Web Design -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: March 27, 2003 11:19 AM To: Tomcat Users List Subject: Re: Registering Servlets Sandra Patricia Hunter wrote: Well, it's printing out the value I assign in the web.xml file. Still it is not recognizing the user/password pairs. I think that I don't have the correct value but I don't know what correct would be? I am using the code from Marty Hall's core servlets book called protectedPage, and it should be straightforward but not. What chapter? Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Registering Servlets
Sandra Patricia Hunter wrote: Four Yep, I ended up finding it (http://pdf.coreservlets.com/) -- I agree with Justin that it's probably the way you're specifying your file path. Remember that even on Windows, it's easier to use Unix-style file paths in Java. (Think of it as writing your code not for Windows but for the Java virtual machine.) Try changing it as he suggests and see if that makes the difference. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Registering Servlets
Well I am finding the file but something else is up: I can enter the password three times and it rejects it and then lets me in after the third time anyway. The real password value is null. I guess I need to do more research into the base64 stuff. Sandra Patricia Hunter Systems Development and Web Design -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: March 27, 2003 12:04 PM To: Tomcat Users List Subject: Re: Registering Servlets Sandra Patricia Hunter wrote: Four Yep, I ended up finding it (http://pdf.coreservlets.com/) -- I agree with Justin that it's probably the way you're specifying your file path. Remember that even on Windows, it's easier to use Unix-style file paths in Java. (Think of it as writing your code not for Windows but for the Java virtual machine.) Try changing it as he suggests and see if that makes the difference. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Registering Servlets
hi, Here's an idea: Don't know of the relevance, but have you tried with an actual password, or a password of blank - - Maybe the problem is that during the uploading, your password is being converted to a blank, or zero length string, which would not be the same as a null string. Just an idea. Paul On Thu, 2003-03-27 at 21:07, Sandra Patricia Hunter wrote: Well I am finding the file but something else is up: I can enter the password three times and it rejects it and then lets me in after the third time anyway. The real password value is null. I guess I need to do more research into the base64 stuff. Sandra Patricia Hunter Systems Development and Web Design -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: March 27, 2003 12:04 PM To: Tomcat Users List Subject: Re: Registering Servlets Sandra Patricia Hunter wrote: Four Yep, I ended up finding it (http://pdf.coreservlets.com/) -- I agree with Justin that it's probably the way you're specifying your file path. Remember that even on Windows, it's easier to use Unix-style file paths in Java. (Think of it as writing your code not for Windows but for the Java virtual machine.) Try changing it as he suggests and see if that makes the difference. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- p niemandt [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Registering Servlets
Interesting idea but no. Still I have to enter the password three times and then it just lets me in. Weird. Value of realPassword is still null. Something is not talking to something else. But what?? Sandra Patricia Hunter Systems Development and Web Design -Original Message- From: p niemandt [mailto:[EMAIL PROTECTED] Sent: March 27, 2003 1:37 PM To: 'Tomcat Users List' Subject: RE: Registering Servlets hi, Here's an idea: Don't know of the relevance, but have you tried with an actual password, or a password of blank - - Maybe the problem is that during the uploading, your password is being converted to a blank, or zero length string, which would not be the same as a null string. Just an idea. Paul On Thu, 2003-03-27 at 21:07, Sandra Patricia Hunter wrote: Well I am finding the file but something else is up: I can enter the password three times and it rejects it and then lets me in after the third time anyway. The real password value is null. I guess I need to do more research into the base64 stuff. Sandra Patricia Hunter Systems Development and Web Design -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: March 27, 2003 12:04 PM To: Tomcat Users List Subject: Re: Registering Servlets Sandra Patricia Hunter wrote: Four Yep, I ended up finding it (http://pdf.coreservlets.com/) -- I agree with Justin that it's probably the way you're specifying your file path. Remember that even on Windows, it's easier to use Unix-style file paths in Java. (Think of it as writing your code not for Windows but for the Java virtual machine.) Try changing it as he suggests and see if that makes the difference. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- p niemandt [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
registering servlets
I'm trying to register a servlet so that I can invoke it like this: http://host/any-path/servletName rather than: http://host/servlet/servletName I've tried adding my servlet to my web.xml using servlet-name and servlet-class, but I still have to go through /servlet/ to get to it: servlet servlet-namesecretServlet/servlet-name servlet-classcoreservlets.ProtectedPage/servlet-class init-param param-namepasswordFile/param-name param-valueC:\\tomcat\\webapps\\ROOT\\WEB-INF\\passwords.properties/param -value /init-param load-on-startup2/load-on-startup /servlet Any suggestions? -Theo
RE: registering servlets
I'm trying to register a servlet so that I can invoke it like this: http://host/any-path/servletName rather than: http://host/servlet/servletName I've tried adding my servlet to my web.xml using servlet-name and servlet-class, but I still have to go through /servlet/ to get to it: servlet servlet-namesecretServlet/servlet-name servlet-classcoreservlets.ProtectedPage/servlet-class init-param param-namepasswordFile/param-name param-valueC:\\tomcat\\webapps\\ROOT\\WEB-INF\\passwords.pro perties/param -value /init-param load-on-startup2/load-on-startup /servlet Any suggestions? You also need to add servlet mappings. The /servlet/MyServlet mapping is in the spec for backwards compatibility. Take a look at the example web.xml(s) to see how mappings work. --- Michael Wentzel Software Developer Software As We Think - http://www.aswethink.com