Create Dynamic Subdomains using Spring? - java

I am developing an application using Spring , jsp and Apache 7.0 server, now suppose i have register domain such as "www.example.com" and in my application the user fills the registration form in which the user is ask to enter his url to name such "123" as soon he submit the form after filling details i want to redirect the him to the newly created URL now in our case "123.example.com"
Now at this movement i have to create sub domain in my code itself before he gets redirected. I have gone through google not find much.
Any help
Thanks in advance.

Related

I have existing Login Application Created in JSP without MVC and I want to convert it into Angularjs SPA

I have Two Textboxes username and Password Which are currently present in JSP and Now I want to convert it into AngularJS SPA Program.
The Login form or the Index page Consists of Username, Password, In-Time, out-Time and Reset.
The Form calls the Java program to store this values or verify the credentials.
I am stuck how to use routing in this existing application. Any Help would be Appreciated!
It would help if you could expand on your question.
However I am taking few assumptions
1. You have an existing JSP application which you want to convert to Angular SPA
2. Your JSP application has a login page which has two textboxes namely UserId & Password and some additional controls.
You are looking at way of how do you still do your authentication with similar setup in Angular SPA, where in your earlier case it was simple Form Post and redirection on successful login.
The simple answer to your question would be create a in memory form(html) using jquery or javascript and do a post action which would return the form body on successful login. Assuming you get a token, store it on client side and authenticate the same on every subsequent request.
However this approach will not help you understand either SPA or Angular.
Here is my advise : First Understand SPA and the respective life cycle of SPA(Angular in particular). This will help you in devising a proper plan to migrate your current JSP application to Angular.
https://www.codeschool.com/beginners-guide-to-web-development/single-page-applications
I will be happy to help if you need any further guidance.

Where to define the login.flt as home page in alfresco-surf framework?

I have new bie to alfresco-surf framework and created one small application. I can access my page using http://localhost:9090/surf/page?p=login url but when i typed only http://localhost:9090/surf its showing
HTTP Status 404 - /surf/
Also I want to use this page for authentication and want to call my Java class to authenticate the user from database. but i don't know how to call my Java class and where to configure.
I create login.xml inside the WEB-INF\classes\alfresco\site-data\pages\login.xml
also create the template instance.
Please help I want to make it as my home page and want to call my custom java class for authentication and want success or failure to render home page.
I got it working.
In \webapps\surf\WEB-INF\classes\alfresco\site-data\configurations there is a file named
default.site.configuration
In this file we have to mention the root page.

Programmatically create subdomains with apache and spring

I am developing an application using Spring , jsp and Apache 7.0 server, now suppose i have register domain such as "www.example.com" and in my application the user fills the registration form in which the user is ask to enter his url to name such "123" as soon he submit the form after filling details i want to redirect the him to the newly created URL now in our case "123.example.com"
Now at this movement i have to create sub domain in my code itself before he gets redirected.
I have gone through google not find much.
Any help
Thanks in advance.
You need to enable wildcard subdomains. That will allow your app to respond to requests from anything.yourdomain.com. Next, your app needs to define a route which converts the subdomain to a variable so that you can use it to scope your database requests to their account. Once the user has their custom subdomain set up, they should register their domain under their account (so that you can look up the account by domain instead of subdomain) then create a CNAME DNS record which points to their subdomain. These principles apply regardless of the language/framework.
You could use a wildcard cname (i.e *.example.com) then use a spring interceptor (https://dzone.com/articles/using-spring-interceptors-your) to determine which subdomain the user requested.

Redirecting to GWT Custom page from application link(other App)

Redirecting application link to Java - GWT Custom page.
Whenever user will login through my APP.
and user hit button(say add record) then redirection should happen i.e. page should redirected to GWT custom page from application link.
How to call servlet when application link hit by button?
after that How to call GWT page from called servlet.
Wants to show GWT custom page with data present in REQUEST.
Hidden fields available on UI Screen which is developed in GI .
These fields can be passed to GWT custom applications launched from the application link.
APP(UI) --> SERVLET---> GWT page(UI with data present in request i.e jsessionid,hidden fields)
what changes need to do in web.xml ?
Plz provide any helpful document,link,sample code and any idea
Hope for the best co-operation
Thanks in advance.
Do you already have a fixed login page (servlet) tah you must use? Then do this:
Window.Location.assign(loginUrl) will take you to a new page. Your GWT app will be "closed" and all state will be lost.
Your login servlet should redirect back to your GWT page when done. Usually this is done by supplying a URL parameter when invoking login page - check the login servlet. Usually something like http://yourserver.com/login?returnTo=GwtAppUrl.
At this point your user is logged in, which means that servlet has set a session cookie. From this point on (until logout or session time-out) your GWT and GWT-RPC will use this session automatically (browser sends session cookie) - you don't have to do anything.
You can pass some data back to GWT by fragment identifier http://yourserver.com/login?returnTo=GwtAppUrl#somePage/parameter1/parameter2. However better option is to just use GWT-RPC to get the data from server.
Otherwise, if you are making everything from scracth, you can use GWT do do the login: How to implement a login page in a GWT app?

Generating unique URL for Unique users in web site

I am developing a web application where users are going to register on it, after that it displays a dashboard for each user.A Dashboard will be unique to the every user,It should be similar to facebook(i.e if user registers to the FB the unique URL address is generated like www.facebook.com/'name-of-theuser'). I want to implement same functionality on my web application ,what is the logic behind this?How do i implement this? Kindly help me.
Technology using for this is: Front-end : HTML and scripts
Server-Side:Servlets and JSP's
I will have a servlet whose url pattern is /users/*
Then for every user I will have urls
/users/usera
/users/userb
/users/userc etc
In the servlet I will check the getContextPath of the HttpServletRequest and serve a unique page based on the contextPath.
This should help you out:
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
And here is a 'Java version' (for use as a ServletFilter):
http://www.tuckey.org/urlrewrite/

Categories

Resources