aspose file tools*
The moose likes Struts and the fly likes How to use, struts 1-- struts-config.xml and struts 2 -- struts.xml together? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use, struts 1-- struts-config.xml and struts 2 -- struts.xml together?" Watch "How to use, struts 1-- struts-config.xml and struts 2 -- struts.xml together?" New topic
Author

How to use, struts 1-- struts-config.xml and struts 2 -- struts.xml together?

prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120
Hi all,
Is it possible to use struts 1-- struts-config.xml and struts 2-- struts.xml within a same application???
Struts 1:
struts-config.xml ---- will be under location 'web/WEB-INF/struts-config.xml'
Struts 2:
struts.xml ---- will be under location 'src/struts.xml'.

I have my login action under struts-config.xml----> but i have to load another action using struts 2, but if i try to do so? im getting some Exceptions...???

I need ranchers help in this... I need to work on both struts 1 and struts 2
actions??

Thanks and Regards
Prabhu
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
What exception are you getting?
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Hi Jesus,

I got exception something like, the action '*.action' could not be loaded... Im not sure. But i think, im using '*.action' for both struts 1 and
struts 2.
Also should there be two different web.xml for struts 1 and struts 2.


Jesus:

if we use struts 1 and struts 2 both in our aplication; then our action should be different like; for struts 1---> it should be as '*.do' and for struts 2 ---> it should be '*.action'.

Im in great trouble i have to finish my module; but im exceeding my schedule. If possible again i will try to reproduce the exact error, which i got.

But what i need now is; I need to call actions from both struts.xml and struts-config.xml file; how should i differ it;

how should my web.xml file be...?
how to point the struts 1 and struts 2 actions....?


Thank you very much for you reply
Im looking forward for further replies.

Thanks
Prabhu.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
To start with, you can only have 1 web.xml. You cannot have 2 in a java web module.

I will look further into the other stuff you mentioned.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Struts 1 uses a servlet, and Struts 2 uses a filter.

To have a set up that have both struts 1 and struts 2:
1. They must have different mapping, like .do for struts 1 and .action for struts 2.
2. Since struts 2 uses a filter, you must put exception that those for struts 1 are not processed by the struts 2 filter. For example, if .do is for struts 1, put exeption that .do are not picked up by struts 2.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Heres a similar conversation. Somebody there mentioned taht he implemented one with both versions. YOu may want to ask him.

http://www.coderanch.com/t/58450/Struts/struts-older-version-co-exist
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Hi Jesus,
Thank you very much, for your views on struts 1 and struts 2.
I will go through the link mentioned above. I will let you know the queries if I have any.

Bye
Prabhu.

prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Hi Ranchers,
Now i can run both struts 1 and struts 2 action in a single application, by defining it in mapping as *.do for struts 1 and *.action for struts 2.
But now im using struts2 tag library, 'struts-tags.tld'. Before it was working fine, when i used '<s:tabbbedpanel> of struts 2 tag, but now its not coming also before i tried using <s:tree> tag and <s:tabbedPanel> it was working fine, but now it is not working. Can you please give me some idea of what may be wrong in my work.

if you need my 'jsp' page to see i can paste it here.

Looking forward for your reply.

Thanks and Regards
Prabhu.
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Also I need a sample code, to check the exception, that struts 1 '*.do' does not look with struts 2 struts.xml file and struts 2 '*.action' does not look struts 1 struts-config.xml file.

Thanks and Regards,
Prabhu.
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Hi Ranchers,
Is there any problems in using libraries, that are used for developing struts 1 application with struts 2. Like say im using several common jars and dwr jars and other webservice jars, and if we do struts 2 within the existing one, will there be any version compatibility.

Please suggest me some ideas; Im looking forward for your ideas.

Thanks and Regards,
Prabhu.

prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Hi Ranchers,
Im using struts 2 '<s:tabbedPanel>' but for me tabs are not displaying; instead the div values given inside the tabbed panel is displayed;

If i see the firefox console; 'dojo is not defined' error is throwing.

Please help me in fixing this; but before i could display the tabbed pane with out any problem; but now im not sure what might have happend.

Thanks and Regards,
Prabhu.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Originally posted by prabhu rangan:
[QB][/QB]


What is the exception? Or what error do you see?
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Hi jesus,

In my firefox, console i see a error message as 'dojo is not defined', But the same application works fine for my friend.


prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Im using 'struts2.0.6 core.jar'. do i need to do something more.
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ taglib prefix="s" uri="/tags/struts-tags" %>
<html>
<head>
<title>Struts 2 Login Application!</title>

<link href="<s:url value="/css/main.css"/>" rel="stylesheet" type="text/css"/>
<s:head theme="ajax" debug="true"/>
</head>
<body>
<s:form action="doLogin.action" method="POST">
<tr>
<td colspan="2">
Login
</td>

</tr>

<tr>
<td colspan="2">
<s:tree theme="ajax" id="root" label="Root">
<s:treenode theme="ajax" id="child1" label="<b>Child 1</b>" />
<s:treenode theme="ajax" id="subchild1" label="SubChild 1">
<s:treenode theme="ajax" id="subchild2" label="SubChild 2" />
<s:treenode theme="ajax" id="subchild3" label="SubChild 3" />
</s:treenode>
<s:treenode theme="ajax" id="child2" label="<b>child 2</b>" />
</s:tree>

</td>

</tr>

<s:textfield name="username" label="Login name"/>
<s assword name="password" label="Password"/>
<s:submit value="Login" align="center"/>


</s:form>


</body>

</html>


This is my sample jsp code: Jesus for the struts-tag.tld, i have defined it in my web.xml, and have mentioned that path in my jsp page.

Go through this page and let me know what im doing wrong.

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Correct me if I am wrong. The same code works when it is pure struts 2?

If that is so, then it should also work when you added struts 1. Check that you have copied all that is needed, e.g. jar files in /lib, and all configurations e.g. the struts.xml. And make sure you put them at the correct folders.
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 120

Yes Jesus you are right. But i did everything correct. For me now If i call an action with *.do, it looks the struts 1 config file and if i call an action as *.action, it looks the struts 2 struts.xml file; That is not the problem for me, im using <s:tabbedPanel>, but the tab is not displayed for me and if i see the console, it shows an error 'dojo is not defined'.

As the javascript files are predefined, in the struts2.0.6-core.jar, there is no need for us to define it. But the error shows as dojo is not defined.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use, struts 1-- struts-config.xml and struts 2 -- struts.xml together?