Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Unable to navigate landing page after login

Avatar

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
vdhim23
Level 3

25-07-2019

Hi,

I am using AEM 6.5 author instance. After login authentication, i have tries several ways to redirect new page. I can see in response, landing page is coming but does not reload in the browser. In the end, login page remains in browser.

1799600_pastedImage_0.png

Below is the POST of my login servlet :

protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) {

    String path = "/content/amc/en/homepage/landing-page.html";

    try {

      String uname = request.getParameter("uname");

      String password = request.getParameter("password");

  //getting some token

      if (StringUtils.isNotEmpty(token)) {

        Map<String, String> params = new HashMap();

// Add token to cookie

        org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper req =

            new org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper(request) {

              public String getMethod() {

                return "GET";

              }

            };

        javax.servlet.RequestDispatcher dispatcher = request.getRequestDispatcher(path);

        dispatcher.include(req, response);

       // AuthUtil.sendRedirect(request,response, path,params);

      } else {

        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

      }

    } catch (Exception e) {

     e.printStackTrace();

    }

  }

With AuthUtil.sendRedirect() below is the response but page not navigate to landing-page in the browser.

1799602_pastedImage_1.png

Any idea to fix this?

Thanks,

Replies

Avatar

Avatar
Coach
Employee
jbrar
Employee

Likes

380 likes

Total Posts

868 posts

Correct Reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Coach
Employee
jbrar
Employee

Likes

380 likes

Total Posts

868 posts

Correct Reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile
jbrar
Employee

25-07-2019

Try changing the Day CQ Root Mapping from [1] and mention the path you want AEM to redirect to after login

[1] http://<host>:<port>/system/console/configMgr/com.day.cq.commons.servlets.RootMappingServlet 

Avatar

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
vdhim23
Level 3

25-07-2019

No, Changing root mapping didn't work.

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

25-07-2019

Hi,

You are including response of target page,you should either redirect or forward.

The main difference is that when you use forward the control is transferred to the next servlet/jsp you are calling, while include retains the control with the current servlet, it just includes the processing done by the calling servlet/jsp(like doing any out.println or other processing).

You can try below:

dispatcher.forward(req, response); 

Avatar

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
vdhim23
Level 3

25-07-2019

Tried forward as well, unfortunately, same behaviour.

org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper req =

  new org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper(request) {

  public String getMethod() {

       return "GET";

    }

  };

javax.servlet.RequestDispatcher dispatcher = request.getRequestDispatcher(path);

dispatcher.forward(req, response);

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

25-07-2019

Hi,

Could you please let us know what are you trying to do / what is the use case?