• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts2 package tag namespace

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

In struts.xml i have included 2 files

<include file="/com/tricky/vo/user.xml"/>
<include file="/com/tricky/vo/project.xml"/>

user.xml uses namespace

tricky


project.xml uses namespace

project



My welcomepage hits the url http://localhost:8080/struts2-login/tricky/showLogin.action from this page i tried to call another action which is having different package name

but the thing is when i am trying to hit , tricky namespace tries to append to url as http://localhost:8080/struts2-login/tricky/project/createproject.action

I want the URL to be like this http://localhost:8080/struts2-login/project/createproject.action (without tricky namespace)

in my jsp i tried to call my action with different options to remove tricky
1) project/createproject
2) /project/createproject
3)../project/createproject

Thanks in advance.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's no reason to use "quote" tags around single words. Just put things like that in actual "quotes".

You neglected to mention how you're creating the URLs. If you're using the <s:url> tag and creating a link to an action in another namespace you'll need to use the "namespace" attribute.
 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info.

I am using <s:a action="../project/createproject">create project</s:a>
 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

You mean to try like the below

<s:url namespace="/project" action="createproject">create project</s:url>

This doesn't help me
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find that unlikely, but okay. Please post your configuration files and the hierarchy of deployed JSPs.
 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

It's working fine.

I have incorporated your inputs of namespace to anchor tag.

<s:a namespace="/project" action="createproject" >create project</s:a>
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, right; I didn't even see the wrong tag was being used! Glad you got it working.
 
Ranch Hand
Posts: 86
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am real newbie to struts... why do we use the namespace attribute in the package tag?\

if i remove the namespace attribute i get the following error.

Aug 26, 2012 7:54:55 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: Y:\Program Files\Java\jre7\bin;Y:\Windows\Sun\Java\bin;Y:\Windows\system32;Y:\Windows;Y:/Program Files/Java/jre7/bin/client;Y:/Program Files/Java/jre7/bin;Y:/Program Files/Java/jre7/lib/i386;Y:\oraclexe\app\oracle\product\11.2.0\server\bin;;Y:\Windows\system32;Y:\Windows;Y:\Windows\System32\Wbem;Y:\Windows\System32\WindowsPowerShell\v1.0\;Y:\eclipse-jee-indigo-SR2-win32\eclipse;;.
Aug 26, 2012 7:54:56 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:DemoStruts' did not find a matching property.
Aug 26, 2012 7:54:56 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-5000
Aug 26, 2012 7:54:56 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 442 ms
Aug 26, 2012 7:54:56 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 26, 2012 7:54:56 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
INFO: Parsing configuration file [struts-default.xml]
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
INFO: Parsing configuration file [struts-plugin.xml]
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
INFO: Parsing configuration file [struts.xml]
Aug 26, 2012 7:54:56 PM org.apache.struts2.config.Settings getLocale
WARNING: Settings: Could not parse struts.locale setting, substituting default VM locale
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory <clinit>
INFO: Setting DefaultObjectTypeDeterminer as default ...
Aug 26, 2012 7:54:56 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-5000
Aug 26, 2012 7:54:56 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Aug 26, 2012 7:54:56 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
Aug 26, 2012 7:54:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 766 ms
Aug 26, 2012 7:54:58 PM org.apache.struts2.components.Form evaluateExtraParamsServletRequest
WARNING: No configuration found for the specified action: 'hello' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
Aug 26, 2012 7:54:58 PM org.apache.struts2.components.Form evaluateExtraParamsServletRequest
WARNING: No configuration found for the specified action: 'hello' in namespace: ''. Form action defaulting to 'action' attribute's literal value.


my struts.xml file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts SYSTEM "struts-2.0.dtd" >
<struts>

<package name="mypack" namespace="/DemoStruts" extends="struts-default">


<action name="hello" class="com.actionclass.LoginAction">

<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>

</struts>
reply
    Bookmark Topic Watch Topic
  • New Topic