vendredi 31 juillet 2015

How to delete useless JSP

On the website that I'm developping, I'm using a lot of Ajax calls to display informations.

Theses Ajax Call are as follow :

function deleteBookingAjax(rowId) {

$.ajax({
    url : "deleteRent.htm", 
    type : "GET",   
    data : {
        "rentId" : rowId
    },
    dataType : 'json',
    cache : false,
    success : function(response) {

        if(response.error) {
            showPopupMessage(response.error, true);
        } 

    },
    statusCode : {
        500 : function() {
            loggingMessage('Error 500');
            reloadBookingTable();
        },
        404 : function() {
            loggingMessage('Error 404');
            reloadBookingTable();
        }

    }
  });
}

To perform this call, I have also Controllers as follow :

@RequestMapping(value = "/deleteRent.htm")
public String deleteRent(Long rentId, HttpServletRequest request, HttpServletResponse response) {

    if (rentId == null) {
        return null;
    }

    try {

        rentService.deleteRent(rentId);

    } catch (Exception e) {

        LOGGER.error(e);
    }

    response.setStatus(HttpStatus.SUCCESS);

    return ViewNames.BOOKINGS_PAGE;
}

But my problem is that : to perform this Ajax call, I need to create a useless JSP file :

<%@page import="net.****.****.web.controllers.RentControllers"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://ift.tt/QfKAz6" prefix="c"%>
<%@ taglib uri="http://ift.tt/18bwTB1" prefix="spring"%>

If I don't create theses files, the Ajax call is not working...

When the file is not in the WEB-INF/ The Ajax call returns :

GET http://ift.tt/1IwR5gM 404 (Not Found)

How can I make it work without theses files (I assume it will be in configurations... but where exactly and how ?), because it's not convinient to have a lot of JSP files but when only few of them have contents...

Thanks in advance. :)

Aucun commentaire:

Enregistrer un commentaire