I want to read the parameters of tomcat context.xml - java

I want to get companyName value which is in context.xml
I am getting null value after writing the code mentioned below
Please help me in getting the value from context.xml. You can even tell other way of getting value from context.xml
NOTE : Don't say to write param in web.xml
Context.xml (Tomcat 7)
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
<Parameter name="companyName" value="My Company, Incorporated"
override="false"/>
</Context>
JSP(index.jsp)
<%# 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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
ServletContext sc= getServletContext();
String testNameValue = sc.getInitParameter("companyName");
%>
<input type="text" value="<%=testNameValue%>">
</body>
</html>
Output
Updated after implementing the solution given below
Exception comes
Exception

You cannot load that way because context.xml is JNDI resource. Please try the following approach:
Tomcat (context.xml)
<Parameter name="companyName" value="My Company, Incorporated" override="false"/>
Java Side
InitialContext context = new InitialContext();
Context xmlNode = (Context) context.lookup("java:comp/env");
String companyName = (String) xmlNode.lookup("companyName");
Spring Side
HomeController.java
#Controller
#RequestMapping("/")
public class HomeController {
#Autowired
private ServletContext servletContext;
#RequestMapping(method=RequestMethod.GET)
public ModelAndView index(ModelAndView mav) throws Exception {
String companyName = servletContext.getInitParameter("companyName");
mav.setViewName("home/index");
mav.addObject("companyName", companyName);
return mav;
}
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
}
View Side
index.jsp
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Home</title>
</head>
<body>
<c:out value="${companyName}"/>
</body>
</html>
The above example has proven successful on my end. My script can read from context.xml file at runtime as shown.

<Environment name="companyName" value="My Company, Incorporated"
type="java.lang.String" override="false"/>
worked better for me than Parameter because the latter was throwing
javax.naming.NameNotFoundException: Name [companyName] is not bound in this Context. Unable to find [companyName]. when trying to get the value using String companyName = (String) xmlNode.lookup("companyName");

Related

Jira spring application plugin not accessing angular assets folder

I am new to Jira and I have created one application and her I have used atlassian-scanner and also I have included angular project everything is working but when any rest request is getting called from main.js it is not working, not sure what is happening is it not considering assets folder or what please help.
Here is my below code for xml web-resource:
<?xml version="1.0" encoding="UTF-8"?>
<bundles>
<web-resource key="client-resources" name="Client Resources">
<resource name="assets/" type="download" location="client/assets/" />
<resource name="main.js" type="download" location="client/main.js" />
<context>com.ngdemo.client-resources</context>
</web-resource>
</bundles>
and my index.html code as below:
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/jira/plugins/servlet/demo/" />
<meta name="decorator" content="atl.general" />
<meta charset="UTF-8">
<title>Angular Demo</title>
$webResourceManager.requireResourcesForContext("com.ngdemo.client-resources")
</head>
<body>
<app-root></app-root>
</body>
</html>
the url which is wrong it is as below:
http://localhost:2990/jira/plugins/servlet/demo/assets/i18n/en.json
but instead I think it should be as below like main.js:
http://localhost:2990/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/-ufur03/713000/b6b48b2829824b869586ac216d119363/1.0.0-SNAPSHOT/_/download/resources/com.demo.ngdemo:client-resources/main.js
http://localhost:2990/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/-ufur03/713000/b6b48b2829824b869586ac216d119363/1.0.0-SNAPSHOT/_/download/resources/com.demo.ngdemo:client-resources/assets/i18n/en.json

Spring MVC CSS, fonts, images wont show in index.html page

I'm new to spring framework and I was able to run my index.html from my localhost but all resources won't show. Below is my folder structure
- src/main
- webapp
- resources
- css (All css files)
- fonts (All font files)
- images (All image files)
- js (All js files)
- static
- index.html (my index.html)
- WEB-INF
My index.html page:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>My First Application</title>
<meta name="description" content="overview & stats" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<!-- bootstrap & fontawesome -->
<link rel="stylesheet" href="/resources/css/bootstrap.min.css" />
<link rel="stylesheet" href="/resources/font-awesome/4.5.0/css/font-awesome.min.css" />
.........
In the "href" I tried changing the directory path multiple times, the page is loading but just a bunch of texts (No css, image, etc)
Do I also need to update my servlet-context.xml or web.xml?
EDIT:
I checked servlet-context.xml and the mapping already exists for resoucres:
<mvc:resources mapping="/static/**" location="/static/" />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
I even added:
<resources mapping="/resources/css" location="/resources/css" />
<resources mapping="/resources/fonts" location="/resources/fonts" />
<resources mapping="/resources/images" location="/resources/images" />
but still won't work.
EDIT 2:
When I go to chrome - inspect - console. This is the log:
springmvc:13 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/font-awesome/4.5.0/css/font-awesome.min.css
springmvc:21 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/ace.min.css
springmvc:18 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/fonts.googleapis.com.css
springmvc:26 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/ace-skins.min.css
springmvc:27 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/ace-rtl.min.css
springmvc:36 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/ace-extra.min.js
springmvc:2149 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery-2.1.4.min.js
springmvc:2159 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/bootstrap.min.js
springmvc:2166 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery-ui.custom.min.js
springmvc:2167 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery.ui.touch-punch.min.js
springmvc:2168 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery.easypiechart.min.js
springmvc:2169 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery.sparkline.index.min.js
springmvc:2170 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery.flot.min.js
springmvc:2171 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery.flot.pie.min.js
springmvc:2172 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery.flot.resize.min.js
springmvc:12 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/bootstrap.min.css
springmvc:18 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/fonts.googleapis.com.css
springmvc:13 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/font-awesome/4.5.0/css/font-awesome.min.css
springmvc:21 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/ace.min.css
springmvc:26 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/ace-skins.min.css
springmvc:27 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/css/ace-rtl.min.css
springmvc:36 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/ace-extra.min.js
springmvc:2149 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery-2.1.4.min.js
springmvc:2159 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/bootstrap.min.js
springmvc:2166 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery-ui.custom.min.js
springmvc:2167 GET http://localhost:8080/$%7BpageContext.request.contextPath%7D/resources/js/jquery.ui.touch-punch.min.js
springmvc:2180 Uncaught ReferenceError: jQuery is not defined
at springmvc:2180
Basically, all the lines in my html that has the:
<link rel="stylesheet" href=
Throws an error.
I tried to change the "href" to:
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/ace-skins.min.css" />
But still the same, css, images, etc won't load.
You need to register Resource Handler in spring to serve static content you can do it by XML way as
or
<mvc:resources mapping="/resources/**" location="/resources/" />
Java config
#Configuration
#EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/resources/**")
.addResourceLocations("/resources/");
}
}
you can also add multiple resource location as
.addResourceLocations("/resources/","classpath:/other-resources/");
use commat to delimit the string and you can provide as many resource location as you want!
Enjoy coding!
Try using relative links like below. Also use Thymeleaf's th:href
<link rel="s`tylesheet" type="text/css" media="all"
href="../../../resources/css/styles.css"`
th:href="#{/resources/css/styles.css}" />
See your deployed directory structure and ensure required files are present in said folders (resources)
Remember to change the relative path ../../ to correct level.
If files not being copied to /resources folder then trying putting them in /main/src/webapp/resources

Apache tomcat error (no from eclipse or xampp tomcat)

I have a problem converting from .docx to .pdf with the Documents4j library, which only happens when I run the application from apache tomcat installation.
However, if the application is executed with Eclipse or XAMPP apache tomcat works correctly.
I have tried Windows 10, Windows 7 and Windows Server 2012 with apache tomcat 8 and 8.5 but the problem persist.
Eclipse or XAMPP do "something" when running apache tomcat that makes it work correctly
jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# page import="com.documents4j.api.IConverter,
com.documents4j.job.LocalConverter,
com.documents4j.api.DocumentType,
java.io.File" %>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<%
IConverter converter = LocalConverter.make();
converter.convert(new File("C:\\test\\test.docx")).as(DocumentType.DOCX).to(new File("C:\\test\\test.pdf")).as(DocumentType.PDF).execute();
%>
</body>
</html>
Dependencies:
<dependencies>
<!-- Local dependencies -->
<!-- https://mvnrepository.com/artifact/com.documents4j/documents4j-local -->
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-local</artifactId>
<version>1.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.documents4j/documents4j-transformer-msoffice-word -->
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-transformer-msoffice-word</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
Error:
org.apache.jasper.JasperException: com.documents4j.throwables.ConverterException: Conversion failed for an unknown reason
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:481)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
com.documents4j.throwables.ConverterException: Conversion failed for an unknown reason
com.documents4j.job.AbstractFutureWrappingPriorityFuture.run(AbstractFutureWrappingPriorityFuture.java:90)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
You can try to specify an explicit base folder for the converter. Application containers often define an implicit temporary folder that is different from the default temporary folder, maybe your setup forbids execution of scripts from within this folder what might cause your troubles. You can check the temporary folder by checking the java.io.tmpdir property at runtime.
As another problem, make sure that your base folder does not contain any spaces. Please update to 1.0.3, too, where the update contains improved handling of such spaces. Maye Tomcat is installed in "Program Files" which might be the problem.

Why isn't my GWT web application running properly?

I'm going through the book: GWT in Action. On chapter I'm working through the very first hello world application. It's all in development mode.
My issue is that the label in my .java file is not showing up when I open the URL webpage. There is nothing being displayed versus the Label("Hello World!") appearing.
EDIT: When at the displayed webpage, I pressed F12 in google chrome to see if I could find anything weird. Got the error: Failed to load resource: the server responded with a status of 404 (Not Found)
HelloWorld.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.6.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.6.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User" />
<source path="client" />
<entry-point class="com.example.gwt.client.HelloWorld"></entry-point>
</module>
HelloWorld.java
package com.example.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
public class HelloWorld implements EntryPoint {
#Override
public void onModuleLoad() {
RootPanel.get().add(new Label("Hello World!"));
}
}
HelloWorld.html
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>HelloWorld</title>
<script type="text/javascript" language="javascript" src=".nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
</body>
</html>
My console is displaying this after I run it as a web application:
[WARN] Server class 'org.eclipse.jetty.servlet.listener.ELContextCleaner' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Users/Qs/Desktop/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.6.0/gwt-2.6.0/gwt-dev.jar' to the web app classpath for this session
For additional info see: file:/C:/Users/Qs/Desktop/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.6.0/gwt-2.6.0/doc/helpInfo/webAppClassPath.html
If you don't specify the rename-to in your gwt.xml as shown below then by default GWT places the generated nocache.js under war directory by the name of location of gwt.xml followed by its name as shown in below snapshot.
<module rename-to="xyz">
For more info have a look at gwt-module dtd.
Please have a look Defining a module and Renaming modules
There are two ways to solve this issue:
define rename-to in gwt.xml that is more preferable over second solution
gwt.xml
<module rename-to="hello">
html
<script type="text/javascript" language="javascript" src="hello/hello.nocache.js"></script>
use default way
html
<script type="text/javascript" language="javascript" src="com.example.gwt.HelloWorld/com.example.gwt.HelloWorld.nocache.js"></script>
Here is a snapshot to make it more clear
Change the src attribute of the script tag in HelloWorld.html to
src="com.example.gwt.client.HelloWorld/com.example.gwt.client.HelloWorld.nocache.js"
If that still doesn't work, run the GWT compiler and look at the files it generates to determine the exact name of the *.nocache.js file.

Struts 2 DisplayTag only shows table of DB information only when form is submitted

I'm using Struts 2 and the Display Tag table formatting tool to display query results from a database (a SELECT * query). I'm running into an odd error. After submitting a record to the database from Add.jsp, it takes me to View.jsp, where the table is correctly displayed. However, if I go to View.jsp directly, or via a hyperlink from the Add.jsp page WITHOUT submitting an entry to the database, it seemingly does not execute the methods necessary to retrieve the database entries into a variable to let the table display. In that case, I end up with a phrase, "nothing to display" where the table should be.
I was told this is most likely a problem with my method names, and the Struts 2 side of things, not any functionality on the Java side. I'm extremely new to Struts, and would appreciate some help at identifying and fixing the bugs. Some code excerpts are below, but I can post the whole thing if required. Also- no errors are shown when View.jsp is loaded, either after form submission or via direct link.
Add.jsp
<%# page contentType="text/html; charset=UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Add Development Environment</title>
</head>
<body>
<div id="main">
<h2>Add Development Environment</h2>
<p><s:a href="View.jsp">View Entries</s:a></p>
<s:actionerror />
<s:form action="doEntries.action" method="post" validate="true">
<s:textfield name="OS" key="label.OS" size="20" />
<s:textfield name="OSVersion" key="label.OSVersion" size="20" />
<s:textfield name="Note" key="label.note" size="20" />
<s:submit method="doEntries" key="label.submit" />
</s:form>
</div>
</body>
</html>
View.jsp
<%# page contentType="text/html; charset=UTF-8" language="java" %>
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="display" uri="http://displaytag.sf.net" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/"WebContent/View.jsp"DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>View Development Environments</title>
</head>
<body>
<div id="main">
<h2>View Development Environments</h2>
<p><s:a href="Add.jsp">Add Entry</s:a></p>
<!--<s:set name="items" value="entries" scope="request"/>-->
<display:table name="entries" class="DevEnvironment" requestURI="" id="itemsList" export="false" pagesize="15">
<display:column property="did" title="id"/>
<display:column property="OS" title="Operating System"/>
<display:column property="OSVersion" title="Operating System Version" />
<display:column property="note" title="Note"/>
</display:table>
</div>
</body>
</html>
DatabaseAction.java
public class DatabaseAction extends ActionSupport{
private static final Logger logger = Logger.getLogger(DatabaseAction.class);
DBO myDBO;
private String OS;
private String OSVersion;
private String note;
private ArrayList<DevEnvironment> entries;
private double offset;
private double limit;
public DatabaseAction(){
super();
//connect to DB
myDBO = new DBO("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/devenvironments?user=root&password=mysqliscool");
}
public String doEntries(){
logger.info("puting stuff in DB! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-==-=-=");
if(myDBO.connect() && myDBO.setEntry(OS, OSVersion, note)){
return "success";
} else {
return "error";
}
}
public ArrayList<DevEnvironment> getEntries() {
logger.info("-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=getEntries called");
entries = myDBO.getEntry(0, -1);
return entries;
}
public void setEntries(ArrayList<DevEnvironment> entries){
this.entries = entries;
}
public String retrieveEntries(){
logger.info("-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=retrieveEntries called");
if(myDBO.connect()){
logger.info("-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=EXECUTING SQL SELECT METHOD");
//entries = myDBO.getEntry(0, -1);
//offset, limit
return "success";
} else {
return "input";
}
}
Struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<action name="doEntries" method="doEntries" class="net.josh.devenvironments.DatabaseAction" >
<result name="success">View.jsp</result>
<result name="input">Add.jsp</result>
</action>
<!--
<action name="retrieveEntries" method="retrieveEntries" class="net.josh.devenvironments.DatabaseAction" >
<result name="success">View.jsp</result>
<result name="input">Add.jsp</result>
</action>
-->
</package>
</struts>
You can get to the View.jsp because it is publicly accessible. As a rule put all JSP's under /WEB-INF the reason for this is that View.jsp will not make sense unless it is backed by an action. If you just go to View.jsp as you are now it does not go though an action it just hits the JSP directly and tries to parse it, the tags not finding any data probably gracefully fail (S2 tags typically do this, can't find the property just give up).
Now with the JSP under the /WEB-INF folder the only way to access it is with "doEntries" (you can leave off the dot action unless you're only filtering .action with s2 but if you don't have good reason you shouldn't be). Of course don't forget to update the action mapping to /WEB-INF/View.jsp
Now you could create another action called view to get there but if all it is going to do is the same thing as "doEntries" there really isn't any point, just use "doEntries".
When you get sick of writing XML (which is good practice but isn't really necessary) add the struts2-conventions-plugin to your class path. After it is added do the following:
Create a new package called struts2, create a class in it like this:
package struts2;
class HelloWorld extends ActionSupport{
public String greetings = "Hello from HelloWorld Class!";
}
Then create a jsp called "hello-world.jsp" under /WEB-INF/content
that has a
<s:property value="greeting"/>
tag now if you enter "hello-world" where index.html is probably located you'll see a little hello message... For most simple cases by following a simple Class to JSP naming convention you can avoid XML all together. If you don't like the convention you can easily override what you don't like, but if you add the conventions plugin to your class path both your xml and future conventions action will live in harmony.
PS: Yes I suppose the HelloWorld class should have getters and setters but it works just fine that way, and makes the example shorter.

Categories

Resources