Reputation: 1623
I created java ee application with this tutorial: http://prideafrica.blogspot.com/2007/04/simple-authentication-servlet-filter.html
but I do not know what libraries are needed. These lines give me the "cannot find symbol" errors:
User user = UserFacade.findByUsername(username);
UserToken tok = Authentication.authenticateUser(user, username, password);
ServletContext context = filterConfig.getServletContext();
and another question. What do I need to add to these files that are in this tutorial?
Thanks. Sorry for bad english.
Upvotes: 1
Views: 2298
Reputation: 8969
You will need to add a Servlet API library into your project. If you use maven to manage dependency, here is the dependency setting:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
You may need to change the version of servlet api depending on what version you want to use and whether your servlet container support it. Since you are creating a Java EE web application, I guess your servlet container should support version 3.0. Normally, Netbeans should already add this library to your classpath when you create a web application project.
If you are using Netbeans and already add servlet api to your classpath, you should be able to use Netbeans to fix what should be imported, Right click in your code editor and then clikc "Fix import". Whatever that cannot be fixed is what you need to take care of it yourself.
You will need to have a better understanding of web authentication, at least how the basic authentication work.
I recommend you to have a look at Spring-Security, it can deal with almost all of authentication problems. However, for a beginner, this can be a little difficult.
Upvotes: 2