Ir ao conteúdo
  • Cadastre-se

Alteração - Código JSP - Login Automático


Posts recomendados

Fala galera....

Não manjo muito de java e tô precisando saber como posso alterar este código para conseguir realizar um login automático. Tipo, ao invés de esperar a entrada do usuário ele já receba os valores no código e redirecione para a página principal... Coloquei o codigo inteiro do arquivo login.jsp e agradeço desde já quem puder me ajudar....

 

<%@ page import="java.util.ResourceBundle" %>
<%@ page import="org.jboss.dashboard.LocaleManager" %>
<%@ page import="org.jboss.dashboard.ui.controller.requestChain.SessionInitializer" %>
<%@ page import="java.util.Locale" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>JBoss Dashboard Builder</title>
 
    <style type="text/css">
        * {
            font-family: Helvetica, Arial, sans-serif;
        }
 
        body {
            margin: 0;
            pading: 0;
            color: #fff;
            background: repeat #55504C;
            font-size: 14px;
            text-shadow: #050505 0 -1px 0;
            font-weight: bold;
        }
 
        li {
            list-style: none;
        }
 
        #dummy {
            position: absolute;
            top: 0;
            left: 0;
            border-bottom: solid 3px #777973;
            height: 250px;
            width: 100%;
            background: #FFFFFF;
            z-index: 1;
        }
 
        #dummy2 {
            position: absolute;
            top: 0;
            left: 0;
            border-bottom: solid 2px #545551;
            height: 252px;
            width: 100%;
            background: transparent;
            z-index: 2;
        }
 
        #login-wrapper {
            margin: 0 0 0 -160px;
            width: 320px;
            text-align: left;
            z-index: 99;
            position: absolute;
            top: 0;
            left: 50%;
        }
 
        #login-top {
            height: 120px;
            width: 201px;
            padding-top: 20px;
            text-align: center;
        }
 
        #login-content {
            margin-top: 120px;
        }
 
        label {
            width: 70px;
            float: left;
            padding: 8px;
            line-height: 14px;
            margin-top: -4px;
        }
 
        input.text-input {
            width: 200px;
            float: right;
            -moz-border-radius: 4px;
            -webkit-border-radius: 4px;
            border-radius: 4px;
            background: #fff;
            border: solid 1px transparent;
            color: #555;
            padding: 8px;
            font-size: 13px;
        }
 
        input.button {
            float: right;
            padding: 6px 10px;
            color: #fff;
            font-size: 14px;
            background: #E22434; /* Non CSS3 browsers. */
            background: linear-gradient(top, #E05A6A 0%,#E22434 100%); /* W3C */
            background: -webkit-gradient(linear, left top, left bottom, from(#E05A6A), to(#E22434)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top, #E05A6A 0%,#E22434 100%); /* Chrome10+,Safari5.1+ */
            background: -moz-linear-gradient(top,  #E05A6A,  #E22434); /* FF */
            background: -o-linear-gradient(top, #E05A6A 0%,#E22434 100%); /* Opera11.10+ */
            filter: progid:DXImageTransform.Microsoft.Gradient(endColorstr='#E22434', startColorstr='#E05A6A', gradientType='0'); /* IE6-9 */
            background: -ms-linear-gradient(top, #E05A6A 0%,#E22434 100%); /* IE10+ */
            text-shadow: #050505 0 -1px 0;
             background-color: #E22434;
            -moz-border-radius: 4px;
            -webkit-border-radius: 4px;
            border-radius: 4px;
            border: solid 1px transparent;
            font-weight: bold;
            cursor: pointer;
            letter-spacing: 1px;
        }
 
        input.button:hover {
            background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#a4d04a), to(#a4d04a), color-stop(80%, #76b226));
            text-shadow: #050505 0 -1px 2px;
            background-color: #E22434;
            color: #fff;
        }
 
        div.error {
            padding: 8px;
            background: rgba(52, 4, 0, 0.4);
            -moz-border-radius: 8px;
            -webkit-border-radius: 8px;
            border-radius: 8px;
            border: solid 1px transparent;
            margin: 6px 0;
        }
    </style>
</head>
 
<body id="login">
 
<div id="login-wrapper" class="png_bg">
    <div id="login-top">
        <img src="<%=request.getContextPath()%>/images/jb_logo.png" alt="JBoss Logo" title="Powered By JBoss"/>
    </div>
 
    <div id="login-content">
        <%
            LocaleManager localeManager = LocaleManager.lookup();
            Locale currentLocale =  localeManager.getCurrentLocale();
            SessionInitializer.PreferredLocale preferredLocale =  SessionInitializer.getPreferredLocale(request);
            if (preferredLocale != null) currentLocale = preferredLocale.asLocale();
            ResourceBundle i18nBundle = LocaleManager.lookup().getBundle("org.jboss.dashboard.login.messages", currentLocale);
 
            String messageKey = (String) request.getSession().getAttribute("login.message");
            if (messageKey == null) messageKey = "login.hint";
        %>
        <h3><%= i18nBundle.getString(messageKey) %></h3>
        <form action="j_security_check" method="POST">
            <p>
                <label><%= i18nBundle.getString("login.username") %></label>
                <input value="" name="j_username" class="text-input" type="text" autofocus/>
            </p>
            <br style="clear: both;"/>

 
            <p>
                <label><%= i18nBundle.getString("login.password") %></label>
                <input name="j_password" class="text-input" type="password"/>
            </p>
            <br style="clear: both;"/>
 
            <p>
                <input class="button" type="submit" value="Sign In"/>
            </p>
 
        </form>
    </div>
</div>
<div id="dummy"></div>
<div id="dummy2"></div>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

@Diego L1M4 Boa noite

 

<input value="" name="j_username" class="text-input" type="text" autofocus/>

altere para

<input value="USUARIO_QUE_FARA_LOGIN_AUTOMATICO" name="j_username" class="text-input" type="text" autofocus/>

 

Depois, 

<input name="j_password" class="text-input" type="password"/>

altere para

<input name="j_password" value="PASSWORD_DO_USUARIO" class="text-input" type="password"/>

E antes da tag 

</body>

coloque

<script type="text/javascript">
  document.forms[0].submit();
</script>

 

Com isso você está setando direto no JSP os dados de login e mandando efetuar o submit dos dados no momento em que a página carregar.

 

Se isso não funcionar, deve haver outra maneira de alterar o código da aplicação para entrar sem login.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...