i would like to remove numerics, symbols and file extensions in the url using netbeans. I tried the following code in web.xml but it aint works
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
Answers are welcome
Download the jar http://urlrewritefilter.googlecode.com/files/urlrewritefilter-4.0.3.jar and XML file http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/4.0/urlrewrite.xml
Add urlrewrite.xml into your web-INF folder then add jar file into your libraries .Then isert this segment into your web.xml which defines the filter mapping
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Consider if your href is <a href="login.jsp">. In your urlrewrite.xml you can see the following code
<rule>
<from>/Authentication</from>
<to >/login.jsp</to>
</rule>
The <to> represents your native URL you can paste your native url here .
The <from> represents the altered URL that will be shown on the browser URL .
After editing the urlrewrite.xml you should include only your altered URL in the href tag i.e after changing the urlrewrite.xml your href should should call tha altered URL
<a href="/Authentication">
Thats it now URL wil shown with http:abc.com/Authentication/ instead of http:abc.com/login.jsp/
Related
I am using Struts 2 convention plugin. I don't want to use any XML based configurations in my application. So, in this case, how how to remove .action extension from URL without using <constant name="struts.action.extension" value="" /> in struts.xml? I am currently using struts.xml file only to remove .action extension. Is there any annotation to remove .actionextension?
There isn't such annotation. You can use struts.properties or define a constant in web.xml like
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.action.extension</param-name>
<param-value>,</param-value>
</init-param>
</filter>
Primefaces doesn't work when primefaces and pretty face use together.
I add flowing jar:
prettyfaces-jsf2-3.3.3.jar
primefaces-4.0-20130605.174828-3.jar
My web.xml code:
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
My pretty-config.xml code:
<rewrite match="^[^(/primefaces_resource/)|^(javascript)]" trailingSlash="append" toCase="lowercase" redirect="301"/>
<url-mapping id="home">
<pattern value="/" />
<view-id value="/" />
</url-mapping>
This image is whithou prittyface( jar and configure):
when I add pretty face jar .then flowing view:
I want to change the url.
example:
(http://localhost:8084/AntSchoolMS/faces/index.xhtml)
I want it to be changed as
(http://localhost:8084/AntSchoolMS/)
please help me .
I use primefaces 3.5 with pretty faces 3.3.3 and works ok. The configuration in your web.xml seems to be ok. Make sure you place pretty-config.xml also in WEB-INF.
About the pretty-config you posted: it doesn't make any sense to have a url-mapping where the pattern and the view-id are the same, so remove it.
Also I don't have that rewrite rule, I have several mappings like the folowing:
<url-mapping id="login">
<pattern value="/login/">
<view-id value="/login.jsf" />
</url-mapping>
Did you try removing that rewrite rule to see what happens?
I've been using these two for some time and they are working as expected. My project used the 3.5 version of primefaces and PrettyFaces 3.3.3.
In my web.xml I did not need to register any filter like you did.
I would also try to remove the rewrite rule as Damian suggests.
Additionally, I would recommend upgrading to the latest version of PrettyFaces - see http://ocpsoft.org/prettyfaces/
This question already has answers here:
Set default home page via <welcome-file> in JSF project
(3 answers)
Closed 7 years ago.
Our application JSF2/weblogic10.3.4 has different client folders deployed in root context as below.
app->webapp->ClientA->index.jsf
->ClientB->index.jsf
If the user request our app with client name, we need to display the corresponding index.jsf.
If the browser request is http://server/ClientA, we should display http://server/ClientA/index.jsf
If the browser request is http://server/ClientB, we should display http://server/ClientB/index.jsf
How can we achieve this?
Register it as <welcome-file> in the web.xml.
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
You only need to create empty files with exactly that name next to the existing index.xhtml files in the same folder, so that the container is fooled that those files really exist, otherwise you will still get 404s.
An alternative is to replace the FacesServlet URL pattern of *.jsf by *.xhtml so that you never need to fiddle with virtual URLs.
...
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
I am working in the struts2 web application.I want to do the mapping of my url such that the extensions like ".jsp" should be eliminated from the url.
So below is the snippet code of my web.xml.I want to do that my url show /login instead of /login.jsp.
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>URLFilter</filter-name>
<filter-class>example.MyFilter</filter-class>
<init-param>
<param-name>onError</param-name>
<param-value>/login.jsp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>URLFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Just access all your JSPs through Actions (and put them somewhere below WEB-INF to enforce this policy). It's easy to do with the "default action" of Struts2:
<action name="login">
<result>/WEB-INF/pages/login.jsp</result>
</action>
I don't know how well this integrates with ServletFilter, maybe you'll have to turn the one mentioned in your web.xml into a Struts2 Interceptor.
You can change url extension using property file as shown in below link :
http://www.aoiblog.com/change-url-extension-in-struts2/
Im trying to create a special web.xml for local development.
I have some tags stored in a separate xml-file which need to be selected and pasted to specific positions inside the final web.xml.
To achieve this I am using the copy and the paste action in the following manner:
<xmltask source="templates.xml">
<copy path="//data/init-param" buffer="initParamBuffer"/>
</xmltask>
<xmltask source="web.xml" dest="web.xml">
<paste path="//web-app/filter[contains(./filter-name,'MyFilter')]
/init-param[contains(./param-name,
'MyInitParameter')]"
position="after" buffer="initParamBuffer"/>
</xmltask>
My intention is to gather ALL init-param Tags from the source File and paste them after the Tag selected in the paste operation.
Also the Part where Im selecting a Tag which contains a tag with a specified content using the contains() function is not working smoothly either.
Maybe there is a better way to form this xpath expression...
update:
As I have written before, I do not know the best approach to this problem. I have read about the possibility to transform using stylesheets, but since the ant-xmltask promised to be a more sleak sollution I have tried this first.
As far as I have come with this approach, it is possible to insert/write tags into the web.xml using this approach. I have succeeded in inserting single init-param tags at locations that where sligtly off, with a less complex expression:
<paste path="//web-app/filter[1]/init-param"
position="after" buffer="initParamBuffer"/>
So my Problem was:
A: I want to select more than one tag into the buffer
B: I want to insert the content of that buffer after a tag specified by a name (not index).
Here is an example for the sources (templates.xml) to insert into the web.xml:
<data>
<init-param>
<param-name>newparam1</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>newparam2</param-name>
<param-value>2</param-value>
</init-param>
</data>
Here is part of an web.xml where the above section is to be pasted:
<web-app>
<filter-mapping>
<filter-name>SomeFilter</filter-name>
<url-pattern>/somePath/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/myPath/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>SomeFilter</filter-name>
<filter-class>foo.bar.SomeFilter</filter-class>
<init-param>
<param-name>SomeInitParameter</param-name>
<param-value>4711</param-value>
</init-param>
</filter>
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>foo.bar.MyFilter</filter-class>
<init-param>
<param-name>MyInitParameter</param-name>
<param-value>0815</param-value>
</init-param>
</filter>
</web-app>
And here is the result I would hope to achieve:
<web-app>
<filter-mapping>
<filter-name>SomeFilter</filter-name>
<url-pattern>/somePath/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/myPath/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>SomeFilter</filter-name>
<filter-class>foo.bar.SomeFilter</filter-class>
<init-param>
<param-name>SomeInitParameter</param-name>
<param-value>4711</param-value>
</init-param>
</filter>
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>foo.bar.MyFilter</filter-class>
<init-param>
<param-name>MyInitParameter</param-name>
<param-value>0815</param-value>
</init-param>
<init-param>
<param-name>newparam1</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>newparam2</param-name>
<param-value>2</param-value>
</init-param>
</filter>
</web-app>
Use XPath Or:
Path|Path
From:
<paste path="//web-app/filter[1]/init-param" position="after" buffer="initParamBuffer"/>
To:
<paste path="//web-app/filter[1]/init-param|//web-app/filter[2]/init-param" position="after" buffer="initParamBuffer"/>
XPath is a Query language operating on the XML Infoset of XML documents. It can only return results or select nodes, but it cannot change the structure of the source XML document or modify it in any way.
A suitable language, designed especially for processing XML documentsand producing new XML documents, is XSLT.
The task specified in your question can be done in a very easy way using XSLT.
Please, provide a complete (but minimal) source XML document, the complete wanted result and specify any rules that the transformation should follow. Then many people will be able to give you correct and useful solutions.