in /jsp/home.jsp
I have a tag like this:
First
In struts-config.xml there is:
<action path="/Load" scope="request" type="myPackage.Load">
<forward name="Success" path="/jsp/home.jsp"/>
</action>
When I execute my webapp and click on the link, the execute method of the Load class is never executed. I don't have exceptions.
In the web.xml file, I have:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
I don't understand what could be the problem.
EDIT
The problem is with the menu3.js that I use to have a collapsible menu
(like the menu on the right here)
Related
Web.xml :
Hi , can't solve the error, spent over two days and the same issue.
Please help ,do I have any mistake ?
<?xml version="1.0" encoding="ISO-8859-1"?>
<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_3_1.xsd"
version="3.1"
metadata-complete="true">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>beer</servlet-name>
<servlet-class>com.example.web</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>
Form.html :
<html><body>
<h1 align="center">Beer Selection Page</h1>
<form method="POST" action="SelectBeer.do">
Select beer characteristics<p>
Color:
<select name="color" size="1">
<option value="light"> light </option>
<option value="amber"> amber </option>
<option value="brown"> brown </option>
<option value="dark"> dark </option>
</select>
<br><br>
<center>
<input type="submit" value="ok"></center>
</form></body></html>
BeerSelect.java
package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got beer color " + c);
}
}
deployment is
C:\Program Files\tomcat\webapps\beer
inside beer is form.html and WEB-INF
inside WEB_INF Web.xml and classes
inside classes is com /example/web/BeerSelect.java
I can log into locathost:8080/beer/form.html but when I chose the color and hit submit the error occur
HTTP Status 404 - /beer/SelectBeer.do
I have compiled BeerSelect.java
type Status report
message /beer/SelectBeer.do "
description The requested resource is not available.
Apache Tomcat/8.0.22
I noticed that your servlet mapping in web.xml maps 'beer' to 'com.example.web'
note this should be 'com.example.web.BeerSelect' according to my understanding.
The directory structure is important. You need to create your directory structure inside Tomcat/webapps/
Example Structure could be:
- Beer/Form.html
- Beer/WEB-INF/web.xml
- Beer/WEB-INF/com/example/web/BeerSelect.class
Note: there should be a folder named WEB-INF not WEB_INF etc this could result in a 404, cause tomcat looks for the mapping(DD) inside WEB-INF
The initial statement inside web.xml ' ...'could also cause a problem. Try to copy that statement form one of the example provided by your Tomcat version.
Hope that helps
I'm trying to use the URLRewriteFilter in combination with a number of different types of resources. It works perfectly fine for static resources and regular servlets. For JAX-RS-based services however, I get a 404.
This is the situation:
There are two web applications:
base
base#nested
Requests for /base/Something/nested/furtherPath need to be forwarded to /base/nested/furtherPath. This implies forwarding from the /base context to the /base/nested context.
To do that, I configured the URLRewrite filter on the /base context:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
The rules (urlrewrite.xml) are as follows:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite use-context="true">
<rule>
<from>/base/([^/]*)/([^/]*)/(.*)</from>
<to type="forward" context="base/nested">/$3</to>
</rule>
</urlrewrite>
The crossContext attribute of the /base context is set to true.
This works perfectly fine for regular servlets and static resources but not for JAX-RS services. I'm doing this in TomEE JAX-RS 1.6.0.
Your help is appreciated!
I have a URL in the following form...
htts://www.mysite/admin/userprofile.do
Using a servlet filter I want to prevent certain things in part of the URL. Using the following in web.xml...
<filter-mapping>
<filter-name>myFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
With an appropriate servlet-filter how could I change url-pattern to only manage the /admin/ portion of the URL (this is an old app that for whatever reason allows an XSS injection only in that portion). Is this possible?
<url-pattern>/admin/*</url-pattern>
You can achieve this like below :
<filter-mapping>
<filter-name>myFilter</filter-name>
<url-pattern>/admin/*</url-pattern>
</filter-mapping>
I have an EJB3 session bean annotated with #WebService(serviceName="MyServiceName", portName="MyPortName"). When it is deployed into Weblogic 11g the service endpoint is located at
host:port/BeanClassName/MyServiceName
Is it possible to change the service endpoint address of the webservice? i.e. to
host:port/my/context/root/something/MyServiceName
I tried to use the weblogic-webservices.xml deployment descriptor, but it requires the webservices.xml descriptor which requires a WSDL location element, but that should be generated by the server and the location of it differs in the dev and prod environments.
Suppose you have an EJB
package com.example;
#Stateless
#WebService
OrganizationService {...}
First you should write a webservices.xml file for it as follows, since its sections will be referenced back from weblogic-webservices.xml where the actual endpoint configuration is done.
webservices.xml (Caution: by adding webservices.xml webservice annotations in classes are overridden!):
<?xml version="1.0" encoding="UTF-8"?>
<webservices xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">
<webservice-description>
<!-- just a label, can be anything you want -->
<webservice-description-name>MyServiceName</webservice-description-name>
<port-component>
<!-- just a label, can be anything you want -->
<port-component-name>MyServicePort</port-component-name>
<!-- Target namespace from wsdl -->
<wsdl-port xmlns:ex="http://example.com/target/name/Space">ex:MyService</wsdl-port>
<!-- Fully qualified class name of the ejb interface/bean providing the service -->
<service-endpoint-interface>com.example.OrganizationService</service-endpoint-interface>
<service-impl-bean>
<!-- The class name of the bean providing the service -->
<ejb-link>OrganizationService</ejb-link>
</service-impl-bean>
</port-component>
</webservice-description>
</webservices>
Then in the weblogic-webservices.xml you can define whatever endpoint you want.
weblogic-webservices.xml:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-webservices xmlns="http://www.bea.com/ns/weblogic/weblogic-webservices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-webservices http://www.bea.com/ns/weblogic/weblogic-webservices/1.0/weblogic-webservices.xsd">
<webservice-description>
<!-- This must match the name given in webservices.xml -->
<webservice-description-name>MyServiceName</webservice-description-name>
<webservice-type>JAXWS</webservice-type>
<port-component>
<!-- This must match the name given in webservices.xml -->
<port-component-name>MyServicePort</port-component-name>
<service-endpoint-address>
<webservice-contextpath>/myContextPath</webservice-contextpath>
<webservice-serviceuri>/myServiceURI</webservice-serviceuri>
</service-endpoint-address>
</port-component>
</webservice-description>
</weblogic-webservices>
I found a solution that adds another endpoint to the one generated from a JAX-WS web service by WebLogic.
I have a web service like this (simplified):
#WebService(name = "ClientService",
portName = "ClientService",
serviceName = "ClientService")
public class ClientWebService {
#WebMethod
public ExtClient findClientDetails(String ref) {
// etc.
}
}
The WebLogic endpoint is <context>/ClientService but I want it to be <context>/client/01.
In web.xml I have:
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>WebServiceServlet</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WebServiceServlet</servlet-name>
<url-pattern>/client/01</url-pattern>
</servlet-mapping>
Now WebLogic offers the web service at both endpoints.
Specifying the URI in web.xml is needed because the JAX-WS library in WebLogic ignores endpoint specifications in sun-jaxws.xml. (In contrast, GlassFish only exposes enpoints that are specified in sun-jaxws.xml.)
I have a series of svc files within a web application, they all worked fine but I have a need to run with aspNetCompatibilityEnabled set to true and now I get the following exception
System.ServiceModel.ServiceActivationException: The requested service, '...' could not be activated. See the server's diagnostic trace logs for more information.
Where are these trace logs that it talks about and what could be causing this?
Thanks
So when turning aspNetCompatibilityEnabled to true, you need to apply changes in a couple of places. Firstly, i'm guessing you've done it in your web.config file. Secondly, you'll need to apply changes to services by decorating the service classes with AspNetCompatibilityRequirements attributes:
C#
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MySampleService
{
}
VB
<Activation.AspNetCompatibilityRequirements( _
RequirementsMode:=Activation.AspNetCompatibilityRequirementsMode.Allowed)> _
public class MySampleService
End Class
You can, if all services allow it, decorate a base service class with this attribute so it's inherited by all services by default.
You could activate extensive logging information by adding the following to your web.config:
<system.diagnostics>
<trace autoflush="true">
<listeners>
</listeners>
</trace>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "WcfDetailTrace.txt" />
</listeners>
</source>
</sources>
</system.diagnostics>
Then you could use SvcTraceViewer.exe to view the log file