apachejspspring-mvcxubuntu

How can a spring application be hosted in a apache server?


I know this is long but please bear with me......

I am using xubuntu. I have a spring mvc project named Fitness Tracker.It has a standard directory structure. I also have apache2 on my machine which i installed using commandline. I have created a file named default1 inside sites-available directory which contains following code:

<VirtualHost *:80>
 ServerName east.example.org
 DocumentRoot /var/www/hello/FitnessTracker/src/main/webapp/WEB-INF/jsp  
<Directory /var/www/hello/FitnessTracker/src/main/webapp/WEB-INF/jsp>
Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>
</VirtualHost>

My httpd.conf contains following code

ServerName localhost     
DirectoryIndex hello.jsp

Additioanlly ,My spring controller name is Hello Controller and it contains following code:-

package com.pluralsight.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HelloController {

    @RequestMapping(value="/greeting")
    public String sayHello(Model model)
{
        model.addAttribute("greeting", "Hello World");
        return "hello";
}
}

Now when i type east.example.org in address bar of my browser i get hello.jsp page which contains code of hello.jsp page(i.e.spring mvc code along with html code).

My requirement is when i start my apache server and type east.example.org in address bar of my browser i want to display greeting.html page. How can this be done?? Note that there exists no page of name greeting.html. But Spring enables us to route the request to hello.jsp page when greeting.html page is requested.

P.S. I have used spring tags inside my jsp page.How can i get access to greeting.html page??


Solution

  • Apache cannot host servlets, It can be done only with Servlet Containers like Tomcat, Jboss etc.

    Refer Difference between the Apache HTTP Server and Apache Tomcat?