error in Struts framework settings - eclipse

I downloaded tomcat, eclipse, Struts framework. Tomcat is working. Where to place eclipse and Struts? I placed eclipse and Struts outside tomcat folder. The needed jar files are stored inside eclipse current folder. I'm getting error.
<%#taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
</head>
<body>
<bean:write name="helloWorldForm" property="message"/>
</body>
</html>
unknown tag:bean.write

Eclipse is an IDE. It's used to develop Java applications. Not just one application, but several ones. You shouldn't place any app-specific jar into the eclipse folder.
Struts (and not strut or struct) is a web framework. Its jars must be put in the WEB-INF/lib folder of your deployed application. In an Eclipse web project, the location for them is (typically) <yourProjectDirectory>/WebContent/WEB-INF/lib.

Related

where to put css and javascript files in eclipse dynamic web project

I decided to add an external css file for a dynamic web project created in eclipse. If I create "fooStyle.css" and refer to it within a jsp file where should I put the css file in the project folder?
<html>
<head><title>Foo</title>
<link rel="stylesheet" href="fooStyle.css">
</head>
<body>....</body>
</html>
[update]
The below link gives me some idea where to put. It says I should put it under theme, but I am not sure this is a directory I have to create manually under WebContent or at the same level as of WebContent.
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Fccwebprj.html

Eclipse -The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

I read all the posts regarding this error but for some reason it does not work for me...
Here is my folder structure,
I get the error as mentioned in my title,
The code of the if_tag.jsp,
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:if> Tag Example</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 2000}">
<p>My salary is: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>
The jstl libraries are located in -
C:\tomcat\webapps\ROOT\WEB-INF\lib
If you are running the maven project as dynamic web project on a server within eclipse, then you should follow the following steps!
open the project properties by right click on the project > properties and select Deployment Assembly.
Click add, select Java build path entries, and choose maven dependencies and then click Finish and Apply.
hope, it may work. it worked for me.
JSTL uses different URIs. You just need to get the right version of it.
You could download using JSTL 1.2 or download the JSTL 1.1 jars.
Javaranch has more detailed list of version/URIs.
I just wanted to note that if you have a project that is Maven based, and you import it into eclipse but receive this error absolute URI, then you might need to follow these directions Maven dependencies not visible in WEB-INF/lib (namely the Deployment assembly step)
To solve this issue copy and paste the jstl-1.2.jar file into your WEB-INF/lib folder directory. This will fix your issue.

JSF 2 eclipse and JBOSS Dev studio + JBOSS tool, how to create a .xhtml file?

I'm new to JSF so maybe it's a noob question.
In eclipse, I create a new JSF project.
After that, I open facex-config.xml, right click -> new view. Here, for every template I choose (html, xhtml, xhtml with xml syntax), eclipse always create a .jsp file.
Now if I try to use JSF 2 tags (like h:link or h:head or h:ajax, jBoss throw errors (and eclipse too)
I solved changing the extension to .xhtml and rewriting the header of the file like this:
<html lang="en" xmlns:f="...." xmlns:h="...">
And with this, all works fine.
The question is: how to create this xhtml file from eclipse instead of manually write it? Isn't JBOSS dev studio supposed to help me? :)
ps:
eclipse: juno
jboss dev studio 6.0
jboss as 7.1.1 final
EDIT:
When the file is created from JBOSS dev studio (xhtml template) this is the result (test.jsp):
<?xml version="1.0" encoding="UTF-8" ?>
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<f:view>
<h:link>test</h:link>
</f:view>
</body>
</html>
I have to rename to .xhtml and remove the lines before !DOCTYPE[...] to get it working.
I'm asking what am I doing wrong with JBOSS dev studio...
Thanks.
D.
i think you should first install JBoss tools to be able to use JSF in your project Install Jboss Tools in Eclipse
then from your eclipse create new web project and from configuration choose Java server faces v2 Project.

How do I deploy an applet using JDeveloper?

I have a simple applet that I have created in JDeveloper 11g R1, deploying to Weblogic server 10.3. This applet has a dependency of ojdbc6.jar. I am deploying as a war file.
When I deploy and browse to the html page the applet loads but I get the following exception:
java.lang.NoClassDefFoundError: oracle/jdbc/pool/OracleDataSource
I can see the ojdbc6.jar in the WEB-INF/lib folder when I expand the .war file.
The HTML of the applet page is as follows:
<HTML>
<HEAD>
<TITLE>
Title
</TITLE>
</HEAD>
<BODY>
<APPLET CODE="com.test.Applet" ARCHIVE="ojdbc6.jar" HEIGHT="800" WIDTH="625" ALIGN="bottom">This browser does not support Applets.</APPLET>
</BODY>
</HTML>
Is there a way to get JDeveloper to deploy so that my dependencies are actually accessible by the server?
If you are using an applet then the JDBC jar needs to be included in the applet JAR, not in the web project WAR.

tag library descriptor in XHTML

Hi i am creating a JSF project, but the autocompletion is not working in eclipse.
For example
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="/WEB-INF/jsf_core.tld"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>JSF 2.0 Hello World</title>
<h:outputStylesheet library="css" name="default.css" />
</h:head>
<h:body>
<h3>JSF 2.0 Hello World Example - hello.xhtml</h3>
<h:form>
<h:inputText value="#{helloBean.name}"></h:inputText>
<h:commandButton value="Click" action="welcome"></h:commandButton>
</h:form>
</h:body>
</html>
the tlds are imported by mens of link.
when i am pressing ctrl+space afiter f: it is not showing the available commands.
so i tried to place the actual file in WEB-INF folder , and import it in the file. Still it is not working.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="/WEB-INF/jsf_core.tld"
xmlns:h="/WEB-INF/jsf_core.tld">
Can anybodt help how to do this.
First of all, you should absolutely not extract the loose TLD file from the JAR and dump them in your webapp. This is recipe for portability trouble. Remove them and undo everything else related to this. You should just have those XML namespaces:
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
As to the concrete problem of autocomplete not working in Eclipse; the behavior is dependent on the Eclipse version and project configuration used. You need to have at least Eclipse Indigo SR1 in order to have proper builtin JSF 2.0 Facelets autocomplete support. Further the project needs to be created as a Dynamic Web Project with the JSF 2.0 Facet enabled.
Alternatives are integrating the Glassfish Eclipse plugin, or JBoss Tools Eclipse plugin. Particularly the JBoss Tools plugin offers a lot of other awesomeness such as EL expression autocompletion and Ctrl+Click navigation.