java - My CSS stopped working -


i have problem css file haven't been able solve while. i'm relatively new in java web technologies , have no clue could've caused that. i'm trying write mvc based application servlets work controllers, jsp's views , database model. homecontroller supposed retrieve names of categories database , forward view (home.jsp). works fine, can display categories in view since i've implemented homecontroller css file have stopped working. ended working controller , awfull view. have no idea problem is.

here's significant files:

web.xml:

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0">    <context-param>     <param-name>databaseurl</param-name>     <param-value>jdbc:postgresql://localhost:5432/buyandsell</param-value>   </context-param>   <context-param>     <param-name>username</param-name>     <param-value>admin</param-value>   </context-param>   <context-param>     <param-name>password</param-name>     <param-value>admin</param-value>   </context-param>    <servlet>     <servlet-name>homecontroller</servlet-name>     <servlet-class>controllers.homecontroller</servlet-class>   </servlet>    <servlet-mapping>     <servlet-name>homecontroller</servlet-name>     <url-pattern>/</url-pattern>   </servlet-mapping>  </web-app> 

homecontroller:

public class homecontroller extends httpservlet {      private static final long serialversionuid = 1l;      private string databaseurl;     private string username;     private string password;      /**      * @see httpservlet#httpservlet()      */     public homecontroller() {         super();     }      @override     public void init(servletconfig config) throws servletexception {        // retrieve database-url, username, password webapp init parameters        super.init(config);        servletcontext context = config.getservletcontext();        databaseurl = context.getinitparameter("databaseurl");        username = context.getinitparameter("username");        password = context.getinitparameter("password");     }      /**      * @see httpservlet#doget(httpservletrequest request, httpservletresponse response)      */     protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         connection conn = null;         statement stmt = null;         requestdispatcher rd = null;         arraylist<category> categories = null;         try {             // indicating proper database driver             class.forname("org.postgresql.driver");                // creating database connection object             conn = drivermanager.getconnection(databaseurl, username, password);             // creating statement object inside our connection object             stmt = conn.createstatement();             // fetching categories names             categories = fetchcategories(stmt);             // setting categories view display             request.setattribute("categories", categories);             rd = request.getrequestdispatcher("/home.jsp");             rd.forward(request, response);         } catch(classnotfoundexception e) {             e.printstacktrace();         } catch (sqlexception e) {             e.printstacktrace();         } {             try {                 if(stmt != null) stmt.close();                 if(conn != null) conn.close();             } catch(sqlexception e) {                 e.printstacktrace();             }         }     }      /**      * @see httpservlet#dopost(httpservletrequest request, httpservletresponse response)      */     protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         doget(request, response);     }      /**      * method responsible fetching categories names database.      * @param reference statement object.      * @return returns object contains names of available categories in array list or null if sqlexception thrown.      */      private arraylist<category> fetchcategories(statement stmt) {         arraylist<category> categories = new arraylist<category>();         string query = "select * categories";         try {             // retrieving data defined query             resultset rset = stmt.executequery(query);             // creating category objects forwarded view             while(rset.next()) {                 int id = rset.getint(1);                 string name = rset.getstring(2);                 int parentid = rset.getint(3);                 categories.add(new category(id, name, parentid));             }             return categories;         } catch(sqlexception e) {             e.printstacktrace();         }            return null;     }  } 

and fragments of home.jsp:

                   <%@ page import="java.util.arraylist" %>                    <%@ page import="models.category" %>                    <ul>                        <%                             arraylist<category> categories = (arraylist<category>) request.getattribute("categories");                             if(categories != null && !categories.isempty()) {                                 for(int i=0; i<categories.size(); i++) {                        %>                                     <li><a href="category?id=<%= categories.get(i).getid() %>"><span><%= categories.get(i).getname() %></span></a>                        <%                                 }                             }                        %>                    </ul>                </div> 

and:

<%@ page language="java" contenttype="text/html; charset=iso-8859-1"     pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head>     <meta http-equiv="content-type" content="text/html; charset=utf-8">     <link rel="stylesheet" href="stylesheet.css" type="text/css" />             <title>buy&amp;sell - online auctions.</title> </head> 

stylesheet.css placed in webcontent folder.

thanks in advance.

edit: css file have been in same folder since beginning.

you've mapped servlet /. mapping means: every request goes servlet. so, when browser sends request /stylesheet.css, request goes servlet instead of going being handled default container-provided servlet serve static file.

map servlet url.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -