0

I want to login in webapp using java and angular. The only part I want to utilize is common views like header and footer using angular ui router which I have already implemented.

Html:

<body>
    <div id="wrap">
        <!--header-->
        <div ui-view="header"></div>
        <!--main content-->
        <div ui-view="content"></div>
    </div>

    <!--footer-->
    <div ui-view="footer"></div>
</body

Now the confusion is once I have logged in, I would like to change the login status in header nav bar to [welcome {user name} + loggedin] etc. If I use java jsp, I am not sure how it works to change the status - may be with tag library?

Example:

    <security-constraint>
    <web-resource-collection>
        <web-resource-name>PRIVATE REST API</web-resource-name>
        <url-pattern>/private*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <description>Have to be a USER</description>
        <role-name>USERS</role-name>
    </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>userauth</realm-name>
    </login-config>
    <security-role>
        <description/>
        <role-name>USERS</role-name>
    </security-role>
</security-constraint>

I find it easy in angular but most of the examples are only based on angular but not angular + java

Also other point of concern is choosing angular+java login over plain java-jsp login? why some people choose the one over other? Before I drill down into building a huge app, I would like to get some expert advice as there are hundreds of different ways in achieving the same

2
  • 1
    Based on your question, I'm not sure how familiar you are with authentication and security in general. If you are concerned about using java and html instead of the java+jsp, you might want to look into a project generator that does a lot of this for you. [jhipster.github.io/] jhipster.github.io Jhipster is one option, it generates a scaffolded java application with security and authentication preconfigured and ready to go. Commented Dec 25, 2015 at 20:56
  • @user2682499 Nice to find out about Jhipster. thank you, but for now I am using plain java+jsp and I am still in the process of learning spring. Jhipster uses spring framework Commented Dec 26, 2015 at 4:55

1 Answer 1

1

If you are going to use Angular, I think you need to reconsider your approach to your technology stack.

If you are using Angular, there is (almost) no reason to use JSPs. Arguably, JSPs are going to be much slower because of all the bloat they cause on the server side, and they will certainly be slower than rendering the front end on the client side using Angular.

Taking that into account, you should think of your Java application as a back end API server that provides only what is needed to populate the front end (or whatever is consuming the responses) - let the front end parse and display the information however it wants. This will help with keeping your code clean through separation of concerns. Also, it does not tie your java code to any particular front end technology so the application can grow and your API can be used for mobile apps, other java apps, etc.

You say that you are just using plain Spring, but your configuration contains spring security elements. Why would you want to create a login using spring but not use spring security?

Maybe these guides from Spring will help you configure your application: https://spring.io/guides/tutorials/spring-security-and-angular-js/ and https://spring.io/blog/2015/01/12/the-login-page-angular-js-and-spring-security-part-ii

Even if you don't use spring or spring security, those articles should clear up a lot of the things you are not clear on.

If you still are uncertain on the first part of your question, I'd advise coming up with a much more specific question. Currently, the question is overly broad.

Sign up to request clarification or add additional context in comments.

2 Comments

I am not using spring right now as I am still in process of learning it.
My mistake. Hopefully those articles help you out a bit. I think as you learn more about angular and whatever MVC framework you use, some of your questions will be answered :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.