java – JSP Login Authentication Script failing (MySQL-backend) web.xml servlet mapping? – Education Career Blog

I am just starting out with JSP in NetBeans 6.9.1 and im trying to make a basic login script for user authentication (sessions will be added later; These are made automatically for every JSP page right?)

The problem I am having is the following.
I followed the tutorial at:
http://www.roseindia.net/jsp/loginbean.shtml

** I made the necessary changes (Database related) **

When running the project I get the login screen presented, as it should.
Although when filling out the details for database authentication, I keep on running into a 404 error: “descriptionThe requested resource () is not available.”

I think the problem might be lying in my web.xml for not mapping the servlets right.
(This was not mentioned in the tutorial though.)

See below for my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" <CANT POST namespace hyperlinks. New user...>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>Login</servlet-name>
        <servlet-class>Login</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>LoginBean</servlet-name>
        <servlet-class>Login</servlet-class>
    </servlet>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>Login.jsp</welcome-file>
    </welcome-file-list>
</web-app>

I hope you guys have time to look at it!

(First time posting here so if there is anything im doing wrong, please let me know.

Regards,

B.

,

First of all, roseindia.net is the worst source ever to learn Java EE (JSP/Servlet/JSF/etc). Its tutorials are cluttered of bad practices and do in no way explain/use the basic concepts properly. It’s maintained by copypaste-addicted amateurs with advertisement incomes as #1 priority. For me, that side is ridiculous, but for new-to-Java EE users it may be very misleading because they don’t know what’s good or bad.

Your functional requirement is sound, but the posted web.xml makes no sense. Firstly, you seem to have declared an ordinary Javabean class (which does not extends HttpServlet) as a Servlet. Secondly, the class is not been placed inside a package, although this may not be the root cause of your problem, packageless classes are invisible to other classes inside a package and instantiating them will only work in very specific environments.

Further I also see the FacesServlet being declared in web.xml. This is part of JSF, a component based MVC framework which is designed on top of Servlet API and can use JSP files as views.

What do you want? Develop a login page using JSF or using “plain” JSP/Servlet?

Anyway, I strongly recommend to blacklist roseindia.net as a learning source and continue with proper tutorials and books. E.g. the tutorials provided by Oracle itself and the JSF2 – The Complete Refernce book of JSF spec lead himself. Further details about tutorials and books depends on whether you’d like to use JSF or not.

See also:

Leave a Comment