Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic

index jsp not working just shows source code on browser

index jsp not working just shows source code on browser  using -'java,spring,jsp,model-view-controller'

In a Spring MVC application, I'm trying to pass a list to a JSP page and show it on a table, but my index.jsp isn't rendered well and just shows source code on browser.

Here is my controller:

package com.orantaj.controllers;

import com.orantaj.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class IndexController {

    EventService eventService;

    @RequestMapping(value = "/")
    public void setEvents(HttpServletRequest request, HttpServletResponse response) {

        try {
            request.setAttribute("basketballEvents", eventService.getBasketballEvents());
            request.getRequestDispatcher("index.jsp").forward(request, response);
        } catch (Exception e) {

And here is JSP:

<%@ page import="com.orantaj.model.BasketballEvent" %>
<%@ page import="java.util.List" %>

        <th>Maç Kodu</th>
        <th>Maç Saati</th>
    <%List<BasketballEvent> basketballEvents = (List<BasketballEvent>) request.getAttribute("basketballEvents");%>
    <%if (basketballEvents != null && basketballEvents.size() > 0) {%>
    <%for (BasketballEvent event : basketballEvents) {%>

        <td><%=event.getHomeTeam() + " " + event.getAwayTeam()%></td>


What could be wrong?

asked Oct 13, 2015 by vijaygupta1980
0 votes

Related Hot Questions

Government Jobs Opening