Create Registration form in Mule - mule

I am a newbie to MuleESB. I want to create a registration form using Mule but I am stuck.
I don't know how to display index.jsp on start-up of your application. I already gone through BookStore example but couldn't get efficient information.
I created a web.xml under src->main->app->webapps->WEB-INF->web.xml
*<web-app....>
<listener>
<listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>*
Any Help or suggestions.

You're missing a web application context directory under: src->main->app->webapps->WEB-INF->web.xml, ie you should have something like: src->main->app->webapps->my-context->WEB-INF->web.xml.
Follow the BookStore example carefully and you should have no difficulty reaching your goal.

Related

j_security_check filter is not working in jboss eap 6.4

I searched fıor a solution on internet and could not find anything.
My Issue is about using j_security_check on my login.jsp to filter and forward it to postloginfilter.java.
To do so I have wrote these lines in web.xml
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login.jsp</form-error-page>
</form-login-config>
</login-config>
<filter-mapping>
<filter-name>PostLoginFilter</filter-name>
<url-pattern>/j_security_check</url-pattern>
</filter-mapping>
But even though when I call a forward like this :
final String requestStr = "/j_security_check?j_username=" + reqUserId
+ "&j_password="+ reqPassword;
req.getRequestDispatcher(requestStr).forward(req, resp);
It is not coming into postloginfilter.java at all. and showing me an empty blank page.
What I want is going to postloginfilter doing the job and following the chain as listed on web.xml.
I also do not see if this filter works too.
<filter-mapping>
<filter-name>PostLoginFilter</filter-name>
<url-pattern>/CreateConnectionAndGetEntityNames.do</url-pattern>
</filter-mapping>
CreateConnectionAndGetEntityNames is actually the one which shows the form. But when I go there breakpoints are not taking effect in postloginfilter.
What might be the reason and how can I solve this issue?
thanks in advance.
As far as I know, the FormAuthenticator is implemented as a JBossWeb valve. As a result, it would be expected for JBoss j_security_check requests not to invoke any application servlet filter. You could implement such filters as valves instead.

Tomcat 7 - JDBCRealm login

I'm using the JDBCRealm with tomcat 7. I want to build a simple login page.
This is my login form:
Login Form
and my web.xml content is:
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/user/login.jsp</form-login-page>
<form-error-page>/user/login-failed.html</form-error-page>
</form-login-config>
</login-config>
I want to redirect the user to some a.jsp page once he was authenticated.
How can I do that?
Thing I understood that you want to redirect your user depends upon the role.Suppose if user is admin then he/she should be redirected to admin.jsp (for example) and if user is on manger role and he/she should be redirected to manager.jsp.
Let us suppose you have two roles admin and manager defined in your JDBCRealm
You can do this by Creating a servlet in project for example LoginServlet.java
So things you have to set are:
Create your login.jsp and login-failed.html as you mentioned.
Create to two jsp pages admin.jsp and manager.jsp under any folder in WebContent of dynamic web project
say :
WebContent/htmlPages/admin.jsp put
<h4>Welcome Admin</h4>text in body tag.
WebContent/htmlPages/manager.jsp put
<h4>Welcome Admin</h4>text in body tag.
In LoginServlet.jsp in doGet MEthod
put this simple code:
if(request.isUserInRole("admin"))
{
response.sendRedirect("htmlPages/admin.jsp");
}
if(request.isUserInRole("manager")){
response.sendRedirect("htmlPages/manager.jsp");
}
After that you have to set welcome-files as the login servletin web.xml
e.g.
Suppose IN web.xml your servlet entry is
<servlet>
<description></description>
<display-name>LoginServlet</display-name>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>Fully classified name of LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/loginServlet</url-pattern>
</servlet-mapping>
Then get url pattern from Servlet Mapping and put it in welcome file list without any slash:
like
<welcome-file-list>
<welcome-file>loginServlet</welcome-file>
</welcome-file-list>
Be sure that no slash has been included. Welcome file attribute should be without slash as i put in code loginServlet.
Run this code.:-) You would get redirected to appropriate jsp page.
You don't. That isn't how FORM authentication works. The user requests a page. If it requires authentication then they receive the login page rather than the page they requested. They then enter their credentials and if valid get presented with the page they originally requests.
If you insist on misusing the FORM authentication process you can set the landingPage attribute of the org.apache.catalina.authenticator.FormAuthenticator. See the docs (http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Form_Authenticator_Valve) for full details.

url rewriting in Struts1

I am developing a web application using Struts1 as web framework. My url pattern in web.xml is:
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
I want to get rid of .do pattern in urls. So if my url is
http://localhost:38330/MyProject/editFunction.do?function=1
i want it to be like http://localhost:38330/MyProject/editFunction/ . How do I acheive this type of url rewriting ?
Thanks for any help
You can use a filter before calling the struts request processor, and this project it's very helpful: http://www.tuckey.org/urlrewrite/
You can map your <url-pattern> to allow prefix, like
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/action/*</url-pattern>
</servlet-mapping>
Then if you do (e.g.) http://localhost:38330/MyProject/action/editFunction/, your struts action will be called (if mapped correctly on struts-config.xml).

How do you create/obtain a cross domain policy for an iis7 wcf service?

The missing link in my IIS7 + Silverlight 3.0 + WCF Service app is the cross domain policy. Are there any instructions on how to create/obtain such a policy. I understand that there are two xml files that need to go in the web root of the app. What do I put in them, how do I format them, does some template exist which indicates which fields need to be filled in? Are there instructions somewhere on msdn which explain how to do this? I'm just about out of possible terms to query google with, any pointers would be appreciated.
Thanks,
Brian
Silverlight looks for clientaccesspolicy.xml (which is specific to silverlight) if thats not found it will fall back on crossdomain.xml which can also be used by flash for instance. You only need one of those (sockets only work with clientaccesspolicy.xml but webclient and http work with both).
Lets stick with clientaccesspolicy.xml for now since there are less caveats and the crossdomain.xml support was only added to catch up with flash since public services like flickr already have one.
The DTD including description for clientaccesspolicy.xml is at this page on MSDN
this basic example should get your started
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*"/> <!-- Allows calls from every domain -->
</allow-from>
<grant-to>
<resource path="/api" include-subpaths="false"/> <!-- Only allows domain/api? to be called nothing else including api.txt, api/foo etc... -->
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
Well, I think this might be the answer, but other answers are certainly welcome for discussion, esp. since we cant close the thread yet anyway...
http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx

Velocity framework servlet

I have a module written in servlets and needs to be recently moved to velocity framework
So in the process I am rewriting the web.xml to create velocity servlet object whcih calls
our original servlet .
Now if this has to be moved to
<servlet>
<servlet-name>VeloServlet</servlet-name>
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
</servlet>
How can we acheive this and what are all changes need to use the existing servlet as it is.
My Existing servlet looks like
<servlet-name>DataBridgeServlet</servlet-name>
<servlet-class>com.jda.pwm.databridge.framework.common.DataBridgeServlet</servlet-class>
<init-param>
<param-name>jda.databridge.config.path</param-name>
<param-value>d:/usr/databridge/conf</param-value>
</init-param>
This is loaded using the url http://localhost:8080/databridge/databridgeservlet
So in the newer case how velocity servlet calls this servlet
Have you looked at the VelocityViewServlet in the Velocity Tools project? This is a useful way of quickly getting Velocity pages on the web.
http://velocity.apache.org/tools/devel/view.servlet.html
You can subclass this for more customizability if desired. And if nothing else, you can look at the source and use this as inspiration to make your own servlet.
You should take a look at: jpublish.org (I am the maintainer, therefore biased :) and replace your Servlet with a simple Action; scripting (BSH, JS) or Java, as you feel fit. My 0.2CAD