Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

URL - getting appended

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I have this strange problem in a sample struts application i am doing. What is happening is that when i redirect the result to index page it is getting appended to the url.
e.g if my url is as follows:
http://localhost:8080/TestApp/mytest/authenticateUser.action

this will get me to a jsp page where i have a logout link.

On click of this link i need to go back to index page.

When i click on logout it is redirecting me to index.jsp but the
URL is getting malformed as shown below

http://localhost:8080/TestApp/mytest/mytest/login.action

this extra mytest is getting appended.

My xml is as follows.
<action name="logout" method="logout" class="com.test.TestAction">
<result name="success">/index.jsp</result>
</action>

Inside TestAction
public class TestAction ....
{
..........
..........
public String logout()
{
//code to invalid session n other stuff
return SUCCESS;
}
}

Any pointers as to why this is happening?

Thanks,

Rohit
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rohit Rai:


When i click on logout it is redirecting me to index.jsp but the
URL is getting malformed as shown below

/mytest[/b]/login.action]http://localhost:8080/TestApp/mytest/mytest/login.action



How are you calling 'logout' action form your jsp page, Pl post the real code of JSP page which contains Action URL !
 
Rohit Rai
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is javascript submit i am using:

function testLogout()
{
document.myForm.action="test/login.action";
document.myForm.submit;
}

Thanks,
Rohit
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try

 
Rohit Rai
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Thanks a lot. Needed a small modification.

document.myForm.action="login.action";

in place of

document.myForm.action="/login.action";

Thanks a lot for the help.

Regards,

Rohit
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome..
Actually that small "/" plays an important role deciding the module in which the action to be searched .. I'm not familiar with Struts 2, anyway I logically provided you with an answer & It helped you !!
 
Rohit Rai
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup you are right.
"The devil lies in the details"

 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic