3 weeks ago - last edited 3 weeks ago
Hi,
following this topics:
and
I would like to change de default landing page after login.
Well, if i tightly follow the topics and start the solution with docker (run.bat build_start), than it works as expected!
While if I create the amps and deploy it to my test environment than, the redirect does not works and, after the login I always see the user dashboard.
May you please help?
Please notice that I can see the package deployed on "Module Deployment" console at ../share/service/modules/deploy.
Thanks a lot.
Kind regards.
3 weeks ago - last edited 3 weeks ago
Hi, I did the following steps.
C:\DATI\Macro\Java\projects-test\eclipse\alfresco>mvn archetype:generate -Dfilter=org.alfresco:
…
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 2
…
21: 4.8.0
...
Choose a number: 31: 21
[INFO] Using property: version = 1.0-SNAPSHOT
Define value for property 'groupId': it.puglia
Define value for property 'artifactId': landing-page-and-url-injection
Define value for property 'package' it.puglia: : it.puglia
Y: y
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:54 min
[INFO] Finished at: 2025-08-06T12:39:26 02:00
[INFO] ------------------------------------------------------------------------
C:\DATI\Macro\Java\projects-test\eclipse\alfresco>cd landing-page-and-url-injection
run.bat build_start for Windows.
After that a docker environment will be created and available at the following links:
http://localhost:8080/alfresco/
Now we can import the SDK on IDE.
Following these topics:
I have implemented a solution with a landing page different from the default one that is tomcat/webapps/share/site-index.jsp.
Here the details:
/src/main/resources/alfresco/web-extension/site-data/pages/landing-page.xml
<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>Welcome</title>
<title-id>page.siteIndex.title</title-id>
<description>Landing page for all users - will forward to user site dashboard</description>
<description-id>page.siteIndex.description</description-id>
<template-instance>landing-page</template-instance>
<authentication>user</authentication>
</page>
/src/main/resources/alfresco/web-extension/site-data/template-instances/landing-page.xml
<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
<template-type>landing-page</template-type>
</template-instance>
/src/main/resources/alfresco/web-extension/site-data/template-types/landing-page.xml
<?xml version="1.0" encoding="UTF-8"?>
<template-type>
<title>Site index landing page template type</title>
<description>Site index landing page JSP Template Type</description>
<!-- Define the rendering processors for this template type -->
<processor mode="view">
<id>jsp</id>
<jsp-path>/landing-page.jsp</jsp-path>
</processor>
</template-type>
/src/main/resources/alfresco/web-extension/site-data/configurations/slingshot.site.configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<name>Slingshot Project</name>
<description>Slingshot Project</description>
<source-id>site</source-id>
<properties>
<theme>lightTheme</theme>
<root-page>landing-page</root-page>
</properties>
</configuration>
/src/main/webapp/jsp/landing-page.jsp
<%--
Copyright 2005 - 2020 Alfresco Software Limited.
This file is part of the Alfresco software.
If the software was purchased under a paid Alfresco license, the terms of the paid license agreement will prevail.
Otherwise, the software is provided under the following open source license terms:
Alfresco is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Alfresco is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
--%>
<%@ page import="org.alfresco.web.site.*" %>
<%@ page import="org.springframework.extensions.surf.*" %>
<%@ page import="org.springframework.extensions.surf.site.*" %>
<%@ page import="org.springframework.extensions.surf.util.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.regex.*" %>
<%@ page import="org.apache.http.client.methods.HttpGet" %>
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
<%@ page import="org.apache.http.impl.client.HttpClients" %>
<%@ page import="org.apache.http.util.EntityUtils" %>
<%
// retrieve userId and context
String userid = (String)session.getAttribute(SlingshotUserFactory.SESSION_ATTRIBUTE_KEY_USER_ID);
RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
// no user dashboard page found! create initial dashboard for this user
if (!context.getObjectService().hasPage("user/" + userid + "/dashboard")) {
Map<String, String> tokens = new HashMap<String, String>();
tokens.put("userid", userid);
FrameworkUtil.getServiceRegistry().getPresetsManager().constructPreset("user-dashboard", tokens);
}
// API call to retrieve sites
String siteApiUrl = request.getScheme() + "://" +
request.getServerName() +
":" + request.getServerPort() +
request.getContextPath() +
"/proxy/alfresco/api/people/" + URLEncoder.encode(userid) + "/sites";
String siteApiUrlResponse = "";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet requestSites = new HttpGet(siteApiUrl);
String jsessionid = session.getId();
requestSites.setHeader("Cookie", "JSESSIONID=" + jsessionid);
siteApiUrlResponse = EntityUtils.toString(httpClient.execute(requestSites).getEntity());
System.out.println("Response JSON: " + siteApiUrlResponse);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
Pattern pattern = Pattern.compile("\\\"shortName\\\"[ ]*:[ ]*\\\"([a-zA-Z0-9_-]+)\\\"");
Matcher matcher = pattern.matcher(siteApiUrlResponse);
List<String> sites = new ArrayList<>();
while (matcher.find()) {
sites.add(matcher.group(1));
}
System.out.println("Site available for user: " + sites);
// if size sites == 1 redirect to documentlibrary
if (sites.size() == 1) {
String siteName = sites.get(0);
String target = request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) + "/documentlibrary";
response.sendRedirect(target);
} else {
// if size sites > 1 redirect to user-sites
String target = request.getContextPath() + "/page/user/user-sites";
response.sendRedirect(target);
}
%>
Rebuild the package and test the solution.
C:\DATI\Macro\Java\projects-test\eclipse\alfresco\landing-page-and-url-injection>run.bat build_start
Please notice that the landing-page.jsp deploy is done manually in tomcat/webapps/share.
Testing the solution, after the login the user will be redirected to the document library of the site where he is a member.
If the user is a member of more than one site than he will be redirected to the the page of all sites.
The dashboard will not be anymore the redirect page after login.
Up to now anything works on docker.
If I build the packages repo and share and deploy the amps on a standalone environment using the apply_amps.sh and after a tomcat restart the package will be available in the Module Deployment page:
But if I try the login I will be always redirect to the dashboard. So, the redirect to landing-page.jsp does not work.
In few words the solution works on docker but doesn't works on standalone env.
May you please help?
Thanks.
Kind regards.
3 weeks ago
I did the following steps.
C:\DATI\Macro\Java\projects-test\eclipse\alfresco>mvn archetype:generate -Dfilter=org.alfresco:
…
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 2
…
Choose a number: 31: 21
...
[INFO] Using property: version = 1.0-SNAPSHOT
Define value for property 'groupId': it.region
Define value for property 'artifactId': landing-page-and-url-injection
Define value for property 'package' it.region: : it.region
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:54 min
[INFO] Finished at: 2025-08-06T12:39:26 02:00
[INFO] ------------------------------------------------------------------------
C:\DATI\Macro\Java\projects-test\eclipse\alfresco>cd landing-page-and-url-injection
After that the docker solution is available at the following addresses:
http://localhost:8080/alfresco/
After that, following these topics:
I have imported the project into the IDE and I have added the following files:
Well, after rebuild the project the solution can be tested and it works on docker!
Now, after the login a user can see the document library of the site if he is a member of one site only, otherwise he will se the page of all the site. Anyway I can't see the dashboard anymore.
If I generate the amps and deploy it on a standalone environment whit apply_amps.sh and after a tomcat restart, the solution doesn't works! The user after the login will always be redirected to dashboard.
Please notice that I can see the amp deployed on Module Deployment:
May you please help?
Thanks.
3 weeks ago - last edited 3 weeks ago
Hi, I did the following steps.
C:\DATI\Macro\Java\projects-test\eclipse\alfresco>mvn archetype:generate -Dfilter=org.alfresco:
…
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 2
…
21: 4.8.0
...
Choose a number: 31: 21
[INFO] Using property: version = 1.0-SNAPSHOT
Define value for property 'groupId': it.puglia
Define value for property 'artifactId': landing-page-and-url-injection
Define value for property 'package' it.puglia: : it.puglia
Y: y
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:54 min
[INFO] Finished at: 2025-08-06T12:39:26 02:00
[INFO] ------------------------------------------------------------------------
C:\DATI\Macro\Java\projects-test\eclipse\alfresco>cd landing-page-and-url-injection
run.bat build_start for Windows.
After that a docker environment will be created and available at the following links:
http://localhost:8080/alfresco/
Now we can import the SDK on IDE.
Following these topics:
I have implemented a solution with a landing page different from the default one that is tomcat/webapps/share/site-index.jsp.
Here the details:
/src/main/resources/alfresco/web-extension/site-data/pages/landing-page.xml
<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>Welcome</title>
<title-id>page.siteIndex.title</title-id>
<description>Landing page for all users - will forward to user site dashboard</description>
<description-id>page.siteIndex.description</description-id>
<template-instance>landing-page</template-instance>
<authentication>user</authentication>
</page>
/src/main/resources/alfresco/web-extension/site-data/template-instances/landing-page.xml
<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
<template-type>landing-page</template-type>
</template-instance>
/src/main/resources/alfresco/web-extension/site-data/template-types/landing-page.xml
<?xml version="1.0" encoding="UTF-8"?>
<template-type>
<title>Site index landing page template type</title>
<description>Site index landing page JSP Template Type</description>
<!-- Define the rendering processors for this template type -->
<processor mode="view">
<id>jsp</id>
<jsp-path>/landing-page.jsp</jsp-path>
</processor>
</template-type>
/src/main/resources/alfresco/web-extension/site-data/configurations/slingshot.site.configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<name>Slingshot Project</name>
<description>Slingshot Project</description>
<source-id>site</source-id>
<properties>
<theme>lightTheme</theme>
<root-page>landing-page</root-page>
</properties>
</configuration>
/src/main/webapp/jsp/landing-page.jsp
<%--
Copyright 2005 - 2020 Alfresco Software Limited.
This file is part of the Alfresco software.
If the software was purchased under a paid Alfresco license, the terms of the paid license agreement will prevail.
Otherwise, the software is provided under the following open source license terms:
Alfresco is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Alfresco is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
--%>
<%@ page import="org.alfresco.web.site.*" %>
<%@ page import="org.springframework.extensions.surf.*" %>
<%@ page import="org.springframework.extensions.surf.site.*" %>
<%@ page import="org.springframework.extensions.surf.util.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.regex.*" %>
<%@ page import="org.apache.http.client.methods.HttpGet" %>
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
<%@ page import="org.apache.http.impl.client.HttpClients" %>
<%@ page import="org.apache.http.util.EntityUtils" %>
<%
// retrieve userId and context
String userid = (String)session.getAttribute(SlingshotUserFactory.SESSION_ATTRIBUTE_KEY_USER_ID);
RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
// no user dashboard page found! create initial dashboard for this user
if (!context.getObjectService().hasPage("user/" + userid + "/dashboard")) {
Map<String, String> tokens = new HashMap<String, String>();
tokens.put("userid", userid);
FrameworkUtil.getServiceRegistry().getPresetsManager().constructPreset("user-dashboard", tokens);
}
// API call to retrieve sites
String siteApiUrl = request.getScheme() + "://" +
request.getServerName() +
":" + request.getServerPort() +
request.getContextPath() +
"/proxy/alfresco/api/people/" + URLEncoder.encode(userid) + "/sites";
String siteApiUrlResponse = "";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet requestSites = new HttpGet(siteApiUrl);
String jsessionid = session.getId();
requestSites.setHeader("Cookie", "JSESSIONID=" + jsessionid);
siteApiUrlResponse = EntityUtils.toString(httpClient.execute(requestSites).getEntity());
System.out.println("Response JSON: " + siteApiUrlResponse);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
Pattern pattern = Pattern.compile("\\\"shortName\\\"[ ]*:[ ]*\\\"([a-zA-Z0-9_-]+)\\\"");
Matcher matcher = pattern.matcher(siteApiUrlResponse);
List<String> sites = new ArrayList<>();
while (matcher.find()) {
sites.add(matcher.group(1));
}
System.out.println("Site available for user: " + sites);
// if size sites == 1 redirect to documentlibrary
if (sites.size() == 1) {
String siteName = sites.get(0);
String target = request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) + "/documentlibrary";
response.sendRedirect(target);
} else {
// if size sites > 1 redirect to user-sites
String target = request.getContextPath() + "/page/user/user-sites";
response.sendRedirect(target);
}
%>
Rebuild the package and test the solution.
C:\DATI\Macro\Java\projects-test\eclipse\alfresco\landing-page-and-url-injection>run.bat build_start
Please notice that the landing-page.jsp deploy is done manually in tomcat/webapps/share.
Testing the solution, after the login the user will be redirected to the document library of the site where he is a member.
If the user is a member of more than one site than he will be redirected to the the page of all sites.
The dashboard will not be anymore the redirect page after login.
Up to now anything works on docker.
If I build the packages repo and share and deploy the amps on a standalone environment using the apply_amps.sh and after a tomcat restart the package will be available in the Module Deployment page:
But if I try the login I will be always redirect to the dashboard. So, the redirect to landing-page.jsp does not work.
In few words the solution works on docker but doesn't works on standalone env.
May you please help?
Thanks.
Kind regards.
3 weeks ago
Hello, you answer has been marked as spam, I approved it.
Could you please edit it and add all the code parts into code blocks, in order to make it clear and more readable?
3 weeks ago
Done.
Thanks.
3 weeks ago
thansk to you 🙂
you took the time to write the answer to your question after figuring out and to come back to improve the answer. this looks great now.
3 weeks ago
Yes but it is not a solution but only the details about my first question.
I hope that someone helps.
Thanks again.
Explore our Alfresco products with the links below. Use labels to filter content by product module.