You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Krzysztof Sobkowiak <kr...@gmail.com> on 2015/04/01 22:05:28 UTC

Re: Jsp Forward not working in the Servlet (Deployed in Servicemix)

Hi

It is difficult to  find out where is you problem without having the whole source code. You write you can access the jsp
and servlet. It means, your web application has been successfully installed and started in ServiceMix.

I can only prove the jsp forward works in ServiceMix.  I have installed the sample from Pax Web in ServiceMix using:

karaf@root>install -s
war:mvn:org.ops4j.pax.web.samples/war-dispatch-jsp/3.1.2/war?Web-ContextPath=/&Bundle-SymbolicName=war-dispatch-jsp
Bundle ID: 230

I had to define the Web-ContextPath, because the sample is no wab but only a war.

After that I can see the bundle metadata

karaf@root>headers 230

war-dispatch-jsp (230)
----------------------
Manifest-Version = 1.0
Bnd-LastModified = 1427842511101
Archiver-Version = Plexus Archiver
Tool = Bnd-2.2.0.20130927-173417
Originally-Created-By = Apache Maven
WAR-URL = mvn:org.ops4j.pax.web.samples/war-dispatch-jsp/3.1.2/war
Built-By = jbonofre
Web-ContextPath = /
Generated-By-Ops4j-Pax-From = mvn:org.ops4j.pax.web.samples/war-dispatch-jsp/3.1.2/war
Build-Jdk = 1.7.0_67
Created-By = 1.7.0_76 (Oracle Corporation)

Bundle-Name = war-dispatch-jsp
Bundle-SymbolicName = war-dispatch-jsp
Bundle-Version = 0
Bundle-ManifestVersion = 2
Bundle-ClassPath = WEB-INF/classes

Import-Package =
    javax.servlet,
    javax.servlet.http,
    org.slf4j;resolution:=optional;provider=paxlogging,
    org.slf4j.spi;resolution:=optional;provider=paxlogging,
    org.apache.log4j.spi;resolution:=optional;provider=paxlogging,
    org.slf4j.helpers;resolution:=optional;provider=paxlogging,
    javax.servlet.jsp.el;resolution:=optional,
    javax.servlet.jsp;resolution:=optional,
    org.apache.commons.logging;resolution:=optional;provider=paxlogging,
    org.apache.log4j;resolution:=optional;provider=paxlogging,
    org.ops4j.pax.web.extender.samples.war.dispatch.jsp;resolution:=optional,
    org.apache.commons.logging.impl;resolution:=optional;provider=paxlogging,
    org.apache.log4j.xml;resolution:=optional;provider=paxlogging

I don't know how your bundle look like. Have you defined the Web-ContextPath metadata? Please check the bundles headers
(with headers command) whether your bundle defines all necessary metadata.

After the installation I can inspect my web applications:

karaf@root>web:list
ID  | State       | Web-State   | Level | Web-ContextPath | Name               
--------------------------------------------------------------------------------
230 | Active      | Deployed    | 80    | /               | war-dispatch-jsp (0)


Next I can access my servlet under following url  http://localhost:8181/wc/dispatch/jsp and the servlet redirects the
call in the jsp page.

Could you check your bundle again and try to find of you have done something different than the Pax Web sample?

Regards
Krzysztof


On 31.03.2015 16:11, ridhi wrote:
> I have a war deployed in ServiceMix 6 Milestone version. I am able to access
> the servlet and jsps from the browser. In my Servlet I have a JSP forward,
> that i am doing by using RequestDispatcher. I have followed the  sample
> which is in
> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/war-dispatch-jsp
> . I don't see any error in the log or exception in console, but it is not
> letting me forward to the jsp from my Servlet. Below are the war related
> features I have installed:
>           *   <feature>war</feature>
> 		<feature>camel-core</feature>
> 		<feature>camel-http</feature>
> 		<feature>camel-servlet</feature>*
>
> I could be missing some feature or something could be wrong the way I am
> doing. Please help me in resolving this.
> My Servlet Code:
>
>              *   rd = super.getServletContext().getNamedDispatcher(
> 				"jsp");
> 		rd.forward(new HttpServletRequestFilter(request, "/success.jsp"),
> 				response);
>
> This is the code, copied from the pax sample :
>
> private static class HttpServletRequestFilter extends
> 			HttpServletRequestWrapper {
>
> 		private String pathInfo;
>
> 		public HttpServletRequestFilter(HttpServletRequest request,
> 				String pathInfo) {
> 			super(request);
> 			this.pathInfo = pathInfo;
> 		}
>
> 		public String getServletPath() {
> 			return "/";
> 		}
>
> 		public String getPathInfo() {
> 			return pathInfo;
> 		}
> 	}*
>
> My web.xml
>
>         *<servlet>
> 		<servlet-name>HomeController</servlet-name>
> 		<servlet-class>com.vnet7.servicehub.servlets.HomeController
> 		</servlet-class>
> 	</servlet>
> 	<servlet-mapping>
> 		<servlet-name>HomeController</servlet-name>
> 		<url-pattern>/HomeController</url-pattern>
> 	</servlet-mapping>
> 	<servlet>
> 		<servlet-name>JspController</servlet-name>
> 		<servlet-class>com.vnet7.servicehub.servlets.JspController
> 		</servlet-class>
> 	</servlet>
> 	<servlet-mapping>
> 		<servlet-name>JspController</servlet-name>
> 		<url-pattern>/jsp</url-pattern>
> 	</servlet-mapping>*
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Jsp-Forward-not-working-in-the-Servlet-Deployed-in-Servicemix-tp5722427.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

-- 
Krzysztof Sobkowiak

JEE & OSS Architect
Apache Software Foundation Member
Apache ServiceMix <http://servicemix.apache.org/> Committer & PMC
Senior Solution Architect @ Capgemini SSC <http://www.pl.capgemini-sdm.com/en/>

Re: Jsp Forward not working in the Servlet (Deployed in Servicemix)

Posted by Krzysztof Sobkowiak <kr...@gmail.com>.
Hi

You write it works when you directly call the servlet. So the problem is probably the jquery. I'm not a gui expert so I
can't help you too much. There are some errors in the log file. Do you see any stacktrace there?

Regards
Krzysztof

On 02.04.2015 17:50, ridhi wrote:
> Hi,
>
>   Thanks for the response! 
>   The only thing I am doing differently than from the pax sample is I am
> calling my servlet from jsp's jquery function and in my servlet i am doing
> some processing and forwarding to jsp. In my other bundles i am using Camel
> routing for my cxf REST services. So, without the installation of
> camel-servlet feature I was not able to access my web application. So I
> installed that, after that I am able to access my web application and from
> my jsp it is going to the servlet and doing processing. But it is not
> forwarding to the jsp, it is staying in the same jsp. There are no scripting
> errors. And one more thing from jquery jsp forwarding is working fine( the
> same thing which I wanted to achieve from my servlet using
> RequestDispatcher). Here is my jquery function.
>
> *function perform(operation) {
> 			$.ajax({
> 				url : "jsp",
> 				headers : {
> 					"Content-type" : 'application/json'
> 				},
> 				type : 'GET'/* ,
> 				success : function(responseText) {
> 					if (op == 2)
> 						window.location = 'getUserDetails.jsp';
> 					else
> 						window.location = 'success.jsp';
> 				},
> 				error : function(responseText) {
> 					window.location = 'error.jsp';
> 				} */
> 			});
> 		
> 	}*
>
>                If I directly access the servlet instead from jsp, the
> forward is working fine. For now, I am managing with the jquery's jsp
> forward. 
>
>                I saw below errors in the log, then i checked for those
> bundles they are active. I tried importing those packages but no luck.
> Please suggest me what needs to be done here.
>
> *ERROR | pool-10-thread-1 | ClassPathUtil                    | 128 -
> org.ops4j.pax.web.pax-web-api - 3.1.2 | BundleWiring is null for:
> AdminServices [303]
> 2015-04-01 16:00:23,266 | ERROR | pool-10-thread-1 | ClassPathUtil                   
> | 128 - org.ops4j.pax.web.pax-web-api - 3.1.2 | BundleWiring is null for:
> AdminServices [303]*
>
>
>
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Jsp-Forward-not-working-in-the-Servlet-Deployed-in-Servicemix-tp5722427p5722446.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

-- 
Krzysztof Sobkowiak

JEE & OSS Architect
Apache Software Foundation Member
Apache ServiceMix <http://servicemix.apache.org/> Committer & PMC chair
Senior Solution Architect @ Capgemini SSC <http://www.pl.capgemini-sdm.com/en/>

Re: Jsp Forward not working in the Servlet (Deployed in Servicemix)

Posted by ridhi <sr...@gmail.com>.
Hi,

  Thanks for the response! 
  The only thing I am doing differently than from the pax sample is I am
calling my servlet from jsp's jquery function and in my servlet i am doing
some processing and forwarding to jsp. In my other bundles i am using Camel
routing for my cxf REST services. So, without the installation of
camel-servlet feature I was not able to access my web application. So I
installed that, after that I am able to access my web application and from
my jsp it is going to the servlet and doing processing. But it is not
forwarding to the jsp, it is staying in the same jsp. There are no scripting
errors. And one more thing from jquery jsp forwarding is working fine( the
same thing which I wanted to achieve from my servlet using
RequestDispatcher). Here is my jquery function.

*function perform(operation) {
			$.ajax({
				url : "jsp",
				headers : {
					"Content-type" : 'application/json'
				},
				type : 'GET'/* ,
				success : function(responseText) {
					if (op == 2)
						window.location = 'getUserDetails.jsp';
					else
						window.location = 'success.jsp';
				},
				error : function(responseText) {
					window.location = 'error.jsp';
				} */
			});
		
	}*

               If I directly access the servlet instead from jsp, the
forward is working fine. For now, I am managing with the jquery's jsp
forward. 

               I saw below errors in the log, then i checked for those
bundles they are active. I tried importing those packages but no luck.
Please suggest me what needs to be done here.

*ERROR | pool-10-thread-1 | ClassPathUtil                    | 128 -
org.ops4j.pax.web.pax-web-api - 3.1.2 | BundleWiring is null for:
AdminServices [303]
2015-04-01 16:00:23,266 | ERROR | pool-10-thread-1 | ClassPathUtil                   
| 128 - org.ops4j.pax.web.pax-web-api - 3.1.2 | BundleWiring is null for:
AdminServices [303]*






--
View this message in context: http://servicemix.396122.n5.nabble.com/Jsp-Forward-not-working-in-the-Servlet-Deployed-in-Servicemix-tp5722427p5722446.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Jsp Forward not working in the Servlet (Deployed in Servicemix)

Posted by ridhi <sr...@gmail.com>.
Forgot to include my bundle headers:

*Symbolic Name	AdminServices
Version	0.0.1.SNAPSHOT
Bundle Location	mvn:com.vnet7.servicehub/AdminServices/0.0.1-SNAPSHOT/war
Last Modification	Thu Apr 02 10:40:25 CST 2015
Start Level	80
Bundle Classpath	WEB-INF/classes,.
Exported Packages	com.vnet7.servicehub.servlets,version=0.0.1.SNAPSHOT
javax.jmdns,version=3.2.0
Imported Packages	com.fasterxml.jackson.databind,version=2.5.2 from
com.fasterxml.jackson.core.jackson-databind (246)
com.fasterxml.jackson.jaxrs.json,version=2.5.2 from
com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider (248)
com.vnet7.servicehub.entities,version=0.0.1.SNAPSHOT from HubJPA (279)
com.vnet7.servicehub.persistence.impl,version=0.0.1.SNAPSHOT from HubJPA
(279)
com.vnet7.servicehub.util,version=0.0.1.SNAPSHOT from HubUtilities (256)
javax.servlet,version=2.6.0 from
org.apache.geronimo.specs.geronimo-servlet_3.0_spec (118)
javax.servlet,version=3.0.0 from
org.apache.geronimo.specs.geronimo-servlet_3.0_spec (118)
javax.servlet.annotation,version=2.6.0 from
org.apache.geronimo.specs.geronimo-servlet_3.0_spec (118)
javax.servlet.annotation,version=3.0.0 from
org.apache.geronimo.specs.geronimo-servlet_3.0_spec (118)
javax.servlet.http,version=2.6.0 from
org.apache.geronimo.specs.geronimo-servlet_3.0_spec (118)
javax.servlet.http,version=3.0.0 from
org.apache.geronimo.specs.geronimo-servlet_3.0_spec (118)
org.apache.cxf.configuration.jsse,version=3.0.2 from org.apache.cxf.cxf-core
(110)
org.apache.cxf.configuration.security,version=3.0.2 from
org.apache.cxf.cxf-core (110)
org.apache.cxf.jaxrs.client,version=3.0.2 from
org.apache.cxf.cxf-rt-rs-client (144)
org.apache.cxf.transport,version=3.0.2 from org.apache.cxf.cxf-core (110)
org.apache.cxf.transport.http,version=3.0.2 from
org.apache.cxf.cxf-rt-transports-http (136)
org.ops4j.pax.web.extender.whiteboard,version=3.1.2 from
org.ops4j.pax.web.pax-web-extender-whiteboard (135)
org.ops4j.pax.web.extender.whiteboard.runtime,version=3.1.2 from
org.ops4j.pax.web.pax-web-extender-whiteboard (135)
org.ops4j.pax.web.jsp,version=3.1.2 from org.ops4j.pax.web.pax-web-jsp (134)
org.ops4j.pax.web.service,version=3.1.2 from org.ops4j.pax.web.pax-web-api
(128)
org.ops4j.pax.web.service.spi,version=3.1.2 from
org.ops4j.pax.web.pax-web-spi (129)
org.ops4j.pax.web.service.spi.model,version=3.1.2 from
org.ops4j.pax.web.pax-web-spi (129)
org.ops4j.pax.web.service.spi.util,version=3.1.2 from
org.ops4j.pax.web.pax-web-spi (129)
org.ops4j.pax.web.utils,version=3.1.2 from org.ops4j.pax.web.pax-web-api
(128)
Service ID 639	Types: org.ops4j.pax.web.service.WebAppDependencyHolder
Service ID 640	Types: javax.servlet.ServletContext
Manifest Headers	Archiver-Version: Plexus Archiver
Bnd-LastModified: 1427992822098
Build-Jdk: 1.7.0_13
Built-By: ridhi
Bundle-ClassPath: WEB-INF/classes, .
Bundle-ManifestVersion: 2
Bundle-Name: AdminServices
Bundle-SymbolicName: AdminServices
Bundle-Version: 0.0.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: com.vnet7.servicehub.servlets; uses:="javax.servlet,
javax.servlet.http"; version="0.0.1.SNAPSHOT", javax.jmdns; version="3.2.0"
Import-Package: javax.servlet; version="[2.4.0, 4.0.0)", javax.servlet.http;
version="[2.4.0, 4.0.0)", org.apache.cxf.jaxrs.client; version="3.0.2",
com.vnet7.servicehub.entities; version="[0.0, 1)",
com.fasterxml.jackson.databind; version="2.5.0",
com.fasterxml.jackson.jaxrs.json; version="2.5.0",
org.apache.cxf.transport.http; version="3.0.2", com.vnet7.servicehub.util;
version="[0.0, 1)", org.ops4j.pax.web.service.spi.util; version="3.1.2",
javax.servlet.annotation; version="3.0",
org.ops4j.pax.web.service.spi.model; version="3.1.2",
org.ops4j.pax.web.service.spi; version="3.1.2", org.ops4j.pax.web.service;
version="3.1.2", org.apache.cxf.configuration.jsse; version="3.0.2",
org.apache.cxf.configuration.security; version="3.0.2",
org.ops4j.pax.web.extender.whiteboard; version="3.1.2",
org.apache.cxf.transport; version="3.0.2",
org.ops4j.pax.web.extender.whiteboard.runtime; version="3.1.2",
com.vnet7.servicehub.persistence.impl; version="[0.0, 1)",
org.ops4j.pax.web.utils; version="3.1.2", org.ops4j.pax.web.jsp;
resolution:=optional; version="3.1.2"
Manifest-Version: 1.0
Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.7))"
Tool: Bnd-2.3.0.201405100607
Web-ContextPath: AdminServices
Webapp-Context: AdminServices
Used Services	
Service #403 of type(s) [org.osgi.service.http.HttpService,
org.ops4j.pax.web.service.WebContainer]*




--
View this message in context: http://servicemix.396122.n5.nabble.com/Jsp-Forward-not-working-in-the-Servlet-Deployed-in-Servicemix-tp5722427p5722447.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.