Eclipse project window shows error, but code editor does not show error

For my jsp file, the code editor does not show an error, but an error is displayed in the project window. I again built my project, cleaned the project, eclipsed the eclipse twice and called cthulhu. But my project still shows an error. How to find the cause and fix the problem?

Eclipse Project -

enter image description here

Jsp file

<%@ 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"> <%@ taglib prefix="mine" uri="DiceFunctions"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> ${mine:rollIt()} </body> </html> 

TLD file -

 <?xml version="1.0" encoding="ISO-8859-1" ?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0"> <tlib-version>1.2</tlib-version> <uri>DiceFunctions</uri> <function> <name>rollIt</name> <function-class>foo.DiceRoller</function-class> <function-signature> int rollDice() </function-signature> </function> </taglib> 

Note. Look at my project structure. Create the foo folder in the web-inf / classes section and place the cube class file inside foo. Otherwise, the project will not work.

0
java eclipse java-ee jsp
May 22 '14 at 22:41
source share
2 answers

How I solved the problem - I was lucky that my luck worked. First, copy all the code from the book. DO NOT create a class folder inside web-inf for your project. In eclipse jee, create a new dynamic web project. Copy all the folders for jsp, html, java code, etc. From the old project to the new. Delete the old project. Create your new project (also try closing eclipse closure to be safe). Your project should now be error free. I have no explanation why this worked.

Alternatively , if your goal is to quickly learn J2ee JSP, etc., I suggest you not use Eclipse natively and manually create web application folders.

Create the following directory structure with all the necessary files:

 C:\APACHE-TOMCAT-7.0.00\WEBAPPS\SAMPLEAPP ¦ MyHtml.html ¦ MyJsp.jsp ¦ +---WEB-INF ¦ DiceRoller.tld ¦ web.xml ¦ +---classes +---foo Dice.class 

Now put all the necessary code for these files and it will work for sure. The moral of this story is that Eclipse is not very well versed in the basics of J2EE / Jsp / Servlets. Manually create your web application folders. I spent 2-3 hours trying to make an eclipse and still could not. I watched the non-eclipse and the code worked after 5 minutes. And ... there was no need to import any banks or expand any classes, etc.

-one
May 23 '14 at
source share
  • First, you defined taglib in web.xml as shown below?

      <jsp-config> <taglib> <taglib-uri>DiceFunctions</taglib-uri> <taglib-location>/WEB-INF/diceRoller.tld</taglib-location> </taglib> </jsp-config> 
  • Secondly, the lib folder in your project is empty, which means that you have not added jstl.jar to your project.




It should look like

 public class DiceRoller { public int rollDice() { return 1; } } 

Find sample code here. JSP Custom Tag Function Example




When I run the html file on tomcat, I get an error message - HTTP Status 404 - / MyJSP / html / MyHtml.html

Export Web Archive (WAR) files

A web archive file (WAR) is a packaged web application that can be exported for testing, publishing, and deploying resources developed as part of a web project.

To export a WAR file from a web project, follow these steps:

  • Right-click the web project folder and select Export from the pop-up menu. Then select the WAR file in the Export window and then click Next.
  • Specify the web project that you want to export (this field is primed if you used the pop-up menu to open the wizard) and specify the location for the new WAR file
  • Optional: You do not have to supply WAR export options, for example, whether or not to include Java ™ source files in the WAR and whether to overwrite any existing resources during the export process. The source files are usually not included in the WAR file, since they are not needed to run the web application by the server.
  • Click Finish.

Read more about Exporting Web Archive Files (WAR)

+1
May 22 '14 at 22:57
source share



All Articles