简体   繁体   English

JSP应用程序登录

[英]JSP Application Login

I created a login with a JSP with a Servlet and a Bean. 我使用带有Servlet和Bean的JSP创建了登录名。

First of all my current code: 首先,我当前的代码:

JSP: JSP:

<body>    
<jsp:useBean id="login" class="login.LoginBean" scope="session"/>

<div class="modal-dialog">
    <div class="loginmodal-container">
        <h1>Login to use BIDeploy</h1><br>
        <form method="post" action="LoginServlet">
            <input type="text" name="user" placeholder="Username">
            <input type="password" name="password" placeholder="Password">
            <input type="submit" name="login" class="login loginmodal-submit" value="Login">
        </form>
    </div>
</div>
</body>

My bean "LoginBean" has just have Getter and Setter. 我的bean“ LoginBean”刚好有Getter和Setter。

Servlet: Servlet的:

@Override
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { 
    LoginBean loginBean = new LoginBean();
    request.setAttribute("loginBean", loginBean);

    loginBean.setUser(request.getParameter("user"));
    loginBean.setPassword(request.getParameter("password"));

    request.getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
}

And my problem starts here: How can I use my username and password to login into SVN, Jira and more? 我的问题从这里开始:如何使用我的用户名和密码登录SVN,Jira等? I need to use the $-Tag 我需要使用$ -Tag

index.JSP 的index.jsp

...
<jsp:useBean id="login" class="login.LoginBean" scope="session"/>

${svnHelper.setup("svn-link",login.username,login.password)}
...

Thanks :) 谢谢 :)

UPDATE: Okay I just have an idea now but i dunno how to realize it: My problem is that I don't save the username and password in the session. 更新:好的,我现在有了一个主意,但我不知道如何实现:我的问题是我没有在会话中保存用户名和密码。

I tried this without success: 我尝试了一下但没有成功:

input type="password" name="password" value="${sessionScope.password}" placeholder="Password"

In your login servlet's doPost() , call: 在您的登录servlet的doPost()中 ,调用:

request.getSession().setAttribute("loggedInUser", loginBean);

And then you can access these attributes with EL, eg: 然后,您可以使用EL访问这些属性,例如:

${sessionScope.loggedInUser.user)

Then, as @MrSimpleMind suggested, you have to find API-s to the SVN, etc., but as far as I understood, you had trouble accessing the variables. 然后,按照@MrSimpleMind的建议,您必须找到SVN等的API-,但是据我所知,您在访问变量时遇到了麻烦。

Turn on some kind of authentication in your web app. 在您的网络应用中打开某种身份验证。 Search for Basic or form-based Authentication. 搜索基本或基于表单的身份验证。 It is very simple and it will give you standard way for handling user credentials, involving JAAS. 这非常简单,它将为您提供处理涉及JAAS的用户凭证的标准方法。

Then you need to look for different login apis for the different vendors. 然后,您需要为不同的供应商寻找不同的登录api。 For example check the Jira REST API . 例如,检查Jira REST API And check the SVN SVNKit which will give you integration possibilities from your web app. 并检查SVN SVNKit ,它将为您提供来自Web应用程序的集成可能性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM