0

I'm new to servlets and JSP so if there is some resource or tutorial that I missed then I can check that out but here's my issue.

I'm running this on a local tomcat server

I've got this application i'm working on going through some tutorials and it works fine when I execute it from my IDE but I tried to create an exploded war in the webapps directory and it is doing unexpected things. All the pages where I used inline java code seem to work fine but I have this line of html

 Lets have some fun: <%= com.luv2code.Step1.FunUtils.makeItLower("FUN FUN FUN")%><br/>

and it seems to be crashing my deployment

 org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [254] in the jsp file: 
 [/jspdemo/Step1/FirstLesson.jsp]
com.luv2code.Step1.FunUtils cannot be resolved to a type
251:             </span>
252:             </p>
253:             <p>2. Call the java class<br/>
254:                 Lets have some fun: <%= 
com.luv2code.Step1.FunUtils.makeItLower("FUN FUN FUN")%><br/>
255:                 Lets have some fun: &lt;%= 
com.luv2code.Step1.FunUtils.makeItLower("FUN FUN FUN")%&gt;<br/>
256:             </p>
257:             <p>

here is my directory structure

enter image description here

When I deploy my webapps folder looks like this

enter image description here So, I can get to http://localhost:8081/luv2code/jspdemo/index.jsp just fine, but I seem to encounter errors when I try to access the files in the classes. Is there something that I need to put in web.xml so that it knows to access these classes? I have a feeling web.xml is the key but I just don't know for sure and I'm so inexperienced I'm getting overwhelmed when I try to look into it. my web.xml is pretty basic but what I've put in there is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

    <display-name>HelloWorld Application</display-name>
    <description>
        This is a simple web application with a source code organization
        based on the recommendations of the Application Developer's Guide.
    </description>

    <servlet>
        <servlet-name>ServletDemo</servlet-name>
        <servlet-class>com.luv2code.Step5.ServletDemo</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ServletDemo</servlet-name>
        <url-pattern>/Step5/ServletDemo</url-pattern>
    </servlet-mapping>

</web-app>

I feel like it's got to be some sort of configuration thing because like I said I can access the pages that are self contained with imbedded java but I get this error when I try to access my own compiled classes from either referenced calls in JSP and the Servlet reference ( http://localhost:8081/luv2code/jspdemo/Step5/ServletDemo) which you can see is declared in my web.xml is giving me a 404.

IdiotDrake
  • 37
  • 9

1 Answers1

0

Apache views each "folder" in the webapps directory as an individual webapp. The problem is that I'm trying to deploy a webapp to a directory nested another level below the webapps directory. I need to either change the config file that says where to look for webapps. How to do this I'm not sure so I just moved the app up to the root directory of the webapps folder which is already mapped as a webapp directory.

I'm sorry if this was a stupid question I'm embarrassed to admit how long it took me to figure this out.

IdiotDrake
  • 37
  • 9