Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Problem with Form-based Authentication ...  RSS feed

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Great Ranchers,

I was trying to implement the Form-based Authentication / Security. But instead of getting login form I am getting an Error saying "Navigation to the webpage was canceled". I am clueless .... Is there something to do that's related to Internet Explorer settings ??? .....

Best Regards
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please provide the code you used?

  • Login page code
  • Error page code
  • web.xml entry


  • Thanks,
    Atul
     
    Maneessh saxena
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Atul ,

    Thanks for your immediate response. files desired are given below....
    Please see & let me know if any discrepancy ....


    -----------------------------------------------------------

    Login.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <img src="images/ATT108667.jpg"><br>
    <form method="post" action="j_security_check">
    Enter Name : <input type="text" name="j_username"><br>
    Enter PassWord : <input type="text" name="j_password"><br>
    <input type="submit" value="Enter">
    </form>
    </body>
    </html>

    --------------------------------------------------------------------------------------------------------

    web.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>TestMemo</display-name>
    <servlet>
    <description></description>
    <display-name>TestServlet</display-name>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>com.lnt.TestServlet</servlet-class>
    <security-role-ref>
    <role-name>manager</role-name>
    <role-link>director</role-link>
    </security-role-ref>
    </servlet>
    <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/TestServlet</url-pattern>
    </servlet-mapping>
    <security-role>
    <role-name>director</role-name>
    </security-role>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>someName</web-resource-name>
    <url-pattern>/TestServlet</url-pattern>
    <http-method>GET</http-method>
    </web-resource-collection>

    <auth-constraint>
    <role-name>director</role-name>
    </auth-constraint>

    <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
    </security-constraint>

    <login-config>
    <auth-method>BASIC</auth-method>
    <form-login-config>
    <form-login-page>/Login.jsp</form-login-page>
    <form-error-page>/Errorpage.jsp</form-error-page>
    </form-login-config>
    </login-config>

    </web-app>



    --------------------------------------------------------------------------------------------------------------------

    TestServlet.java



    package com.lnt;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;


    public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;


    public TestServlet() {
    super();
    }

    protected void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    //super.doGet(request, response);
    //This Is The Constrainrd Resource ......
    }

    protected void doPost(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    super.doPost(request, response);
    }
    }


    --------------------------------------------------


    Thanks & Regards
     
    Atul Samnerkar
    Ranch Hand
    Posts: 44
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Change the <auth-method> from "BASIC" to "FORM"
    <auth-method>FORM</auth-method>


    Cheers..
     
    Maneessh saxena
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>


    Sorry It was by mistake .... Actually that's what my problem is even if I had "auth-method>FORM</auth-method>" my customized login page was not coming instead an error was coming saying "Navigation to the webpage was canceled". I don't know why .....
     
    Maneessh saxena
    Ranch Hand
    Posts: 125
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,

    I got why it was not working ... actually I did not set the " SSL on Tomcat ", That's why it was not working .....

    Thanks for your support ...

    Best Regards
     
    Why is the word "abbreviation" so long? And this ad is so short?
    Programmatically Create PDF Using Free Spire.PDF with Java
    https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!