Thymeleaf multiple result in condition

I want to check some condition basing on statement ‘myStatus’ and if it is true – change background color to red and disable element (user could not click it), if it is false – change color to green. I know how to change color (and it works fine):

th:style="${myObject.myStatus} == true ? 'background-color:red' : 'background-color:green'"

but how is it possile to disable element in this line? I tried something like:

    th:style="${myObject.myStatus} == true ? 'background-color:red'  'disabled:false' : 'background-color:green'"

    th:style="${myObject.myStatus} == true ? 'background-color:red'  'disabled' : 'background-color:green'"

    th:style="${myObject.myStatus} == true ? 'background-color:red' & disable : 'background-color:green'"

but it doesnt work… how is it possible to solve this problem?

How to secure the JS application before ‘Cannot read property“…”’?

I get a list of users using the controller.

@ApiOperation(value = "Find users")
@GetMapping(produces = MediaTypes.HAL_JSON_VALUE)
PagedResources<UserSearchResultResource> findUsers(
        @ApiParam(value = "Search for a phrase") @RequestParam(required = false) final String q,
        @PageableDefault(sort = {"id"}, direction = Sort.Direction.ASC) final Pageable page,
        final PagedResourcesAssembler<UserSearchResult> assembler
) {"Called with q {}, page {}", q, page);

    // Build the self link which will be used for the next, previous, etc links
    final Link self = ControllerLinkBuilder
                            .findUsers(q, page, assembler)

    return assembler.toResource(this.userSearchService.findUsers(
            q, page
    ), this.userSearchResultResourceAssembler, self);

Users are returned using the object PagedResources. For example, this object looks like this Download elements using Angular

        url: '/api/v1.0/users',
        method: "GET",
        params: {
            q: angular.element('#search-value').val(),
            size: parseInt($scope.size),
            page: (parseInt($
        .then(function (response) {
            $scope.users =;

Everything is fine until the controller returns an object without elements, because there are no such users
JS throws the error

TypeError: Cannot read property 'userSearchResults' of undefined
at users.js:33
at angular.js:16832
at m.$digest (angular.js:17971)
at m.$apply (angular.js:18269)
at l (angular.js:12387)
at XMLHttpRequest.A.onload (angular.js:12541) "Possibly unhandled rejection: {}"

Because the object does not have a list of users at this time


How can I create support for this error so that in the case when there are no users with the given name, it would set an empty list in Angular.

Updating Lamda Expression 1.6 to 8 or Higher

I just want to ask if someone can translate this to a normal method or convert this to lamda expression 8 or higher

 public void waitUntilDocIsReady() 
    new WebDriverWait(driver, 30).until((ExpectedCondition<Boolean>) wd ->
    ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));

Thank you everyone! I’m really sorry for asking this question. I hope someone can answer this.

CSS and JS not loading on JSP servlet mapping

When I don’t have a servlet attached to a / in servlet mapping


All my css and javascript frameworks are loading. However, when I added this part of code in web.xml, none of the css and javascript are loading. How do I ensure that the servlet knows that it is a css/js file instead of a method?









public class ControllerServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private BookDAO bookDAO;

    public void init() {
        String jdbcURL = getServletContext().getInitParameter("jdbcURL");
        String jdbcUsername = getServletContext().getInitParameter("jdbcUsername");
        String jdbcPassword = getServletContext().getInitParameter("jdbcPassword");

        bookDAO = new BookDAO(jdbcURL, jdbcUsername, jdbcPassword);


    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String action = request.getServletPath();

        try {
            switch (action) {
            case "/new":
                //showNewForm(request, response);
            case "/insert":
                //insertBook(request, response);
            case "/delete":
                //deleteBook(request, response);
            case "/edit":
                //showEditForm(request, response);
            case "/update":
                //updateBook(request, response);
                listBook(request, response);
        } catch (SQLException ex) {
            throw new ServletException(ex);

    private void listBook(HttpServletRequest request, HttpServletResponse response)
            throws SQLException, IOException, ServletException {
        List<Book> listBook = bookDAO.listAllBooks();
        request.setAttribute("listBook", listBook);
        RequestDispatcher dispatcher = request.getRequestDispatcher("BookList.jsp");
        dispatcher.forward(request, response);

jsp page

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

        <!-- JS -->     
        <script src='static/js/bootstrap.min.js'></script>
        <script src='static/js/vue.min.js'></script>

        <!-- CSS -->
        <link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="static/css/common.css">
        <h1>Books Management</h1>
            <a href="new">Add New Book</a>
            <a href="list">List All Books</a>

    <div align="center">
        <table border="1" cellpadding="5">
            <caption><h2>List of Books</h2></caption>
            <c:forEach var="book" items="${listBook}">
                    <td><c:out value="${}" /></td>
                    <td><c:out value="${book.title}" /></td>
                    <td><c:out value="${}" /></td>
                    <td><c:out value="${book.price}" /></td>
                        <a href="edit?id=<c:out value='${}' />">Edit</a>
                        <a href="delete?id=<c:out value='${}' />">Delete</a>                     

Postman link checker crawl on one page

I am using postman link checker ( Is there any way to check all links that are on xx page and not crawl those links?

// get environment variables
var start_url = postman.getEnvironmentVariable('start_url');
var root_url = postman.getEnvironmentVariable('root_url');
var links = JSON.parse(postman.getEnvironmentVariable('links'));
var url = postman.getEnvironmentVariable('url');
var index = parseInt(postman.getEnvironmentVariable('index'));

// increment index counter to access links in array to check
index = index + 1;

// test if link works
if (responseCode.code > 400) {
    //console.log("This link is broken: ", url);
    tests[("This link is broken: ", url)] = false;
} else {
    tests["Link works"] = true;

// if the current url includes the start_url, then this is an internal link and we should crawl it for more links
if (url.includes(start_url)) {

    // load the response body as HTML using cheerio, get the <a> tags
    var $ = cheerio.load(responseBody);

    $('a').each(function (index) {

        var link = $(this).attr('href');

        // add links to the links array if not already in there
        // if you have additional links you would like to exclude, for example, ads, you can add this criteria as well
        if (!links.includes(link)) {

// if we've gone through all the links, return early
if (links.length - 1 === index) {
    console.log('no more links to check');

// if link is a relative one, prepend with root_url
url = links[index]
if (! /^https?:///.test(url)) {
    url = root_url + url;

// update environment variable values
postman.setEnvironmentVariable("links", JSON.stringify(links));
postman.setEnvironmentVariable("url", url);
postman.setEnvironmentVariable("index", index);

// continue calling the same request until all links are checked
postman.setNextRequest('Check URL');