• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

I have wrote simple hello world program of Sturts can any one explain me the Flow of this program...

 
Greenhorn
Posts: 16
Mac Oracle Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have wrote simple hello world program of struts can any one explain me the flow of this program...



-----------------struts-config.xml-----------------

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
<form-beans>
<form-bean name="helloWorldForm" type="com.vaannila.form.HelloWorldForm"/>
</form-beans>

<global-forwards>
<forward name="helloWorld" path="/helloWorld.do"/>
</global-forwards>

<action-mappings>
<action path="/helloWorld" type="com.vaannila.action.HelloWorldAction" name="helloWorldForm">
<forward name="success" path="/helloWorld.jsp" />
</action>
</action-mappings>

</struts-config>

-----------------web.xml-----------------

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>StrutsExample1</display-name>

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>

<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>


-----------------index.jsp-----------------
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<logic:redirect forward="helloWorld"/>


-----------------helloWorld.jsp-----------------

<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
</head>
<body>
<bean:write name="helloWorldForm" property="message"/>
</body>
</html>


-----------------HelloWorldForm.java-----------------

package com.vaannila.form;

import org.apache.struts.action.ActionForm;

public class HelloWorldForm extends ActionForm
{
private static final long serialVersionUID = -473562596852452021L;

private String message;

public String getMessage()
{
return message;
}

public void setMessage(String message)
{
this.message = message;
}
}




-----------------HelloWorldAction.java-----------------

package com.vaannila.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.vaannila.form.HelloWorldForm;

public class HelloWorldAction extends Action
{
@Override
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response
) throws Exception
{
HelloWorldForm hwForm = (HelloWorldForm) form;
hwForm.setMessage("Hello World");
return mapping.findForward("success");
}
}
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused - you wrote this code, but you don't know how it works? Given that, why did you write it the way you did? And what confuses you about it?

(In the future, please don't post in all uppercase letters. It's considered shouting, and thus rude, all over the 'net: KeepItDown. It's also unnecessarily hard to read.)
 
GajanaN Chalke
Greenhorn
Posts: 16
Mac Oracle Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for telling me about Uppercase formality i'll never post queries like previous one in future,
actually wrote this code as per my friends suggestion but i'm not able to understand the flow of execution.

Note: I'm using eclipse as IDE.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the package names it seems that you are using Struts 1 - that has been dead and obsolete for years. If you're just starting to learn it, I strongly advise to use a current web framework, Struts 2 maybe, or one of the numerous other frameworks that are still maintained. Struts 1 has well-documented security holes that should prevent any app based on it from being released into the wild anyway.

If for some reason (which one?) you insist on using Struts 1, then you may want to start by working through a few tutorials. Search for "struts 1 introduction/tutorial" or some such phrase, and you'll find plenty.
 
GajanaN Chalke
Greenhorn
Posts: 16
Mac Oracle Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I've just joined company as jr developer and i'm under training. and all the company employee use struts1. so it is obvious that i have to use the same.

can you just tell me the flow of this program?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I shudder to think of the security implications of using Struts 1 at this point. That's professionally irresponsible.

I know you're looking for a different answer, but I really think the best way to learn a framework is to, well, learn it - read some introductions, read a few tutorials, follow their example codes, and it should become clear how the different parts of a Struts app work together. http://struts.apache.org/release/1.3.x/userGuide/index.html would be an obvious starting point. There's really little point in repeating all that here.

I also think that if your company wants you to learn it, then some of the more experienced developers should help you, like the person who suggested you write this code. I think that would be a more reasonable approach than leaving a junior developer to learn on their own without any guidance (not that that would be impossible if you follow the tutorial).
 
Marshal
Posts: 5807
371
IntelliJ IDE Python TypeScript Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

GajanaN Chalke wrote:all the company employee use struts1. so it is obvious that i have to use the same.


While I completely understand that you need to understand Struts 1 in order to work with your company's existing products, it does not mean that you should not be looking to the future and learning the newer technologies that have replaced it, such as Struts 2 as Ulf suggested.

Remember that the development team in any company is the most qualified group of people to make decisions on what technology to use in their applications. So now that you know there are serious security issues with Struts 1 that are never going to be addressed, then it's up to you and your team to lead the effort to migrate to something better. As a junior developer I'm not suggesting that it's all up to you to do all this, but there's absolutely no reason why you can't have a discussion with your team about it. That kind of forward thinking should always be well received.
 
GajanaN Chalke
Greenhorn
Posts: 16
Mac Oracle Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:

GajanaN Chalke wrote:all the company employee use struts1. so it is obvious that i have to use the same.


While I completely understand that you need to understand Struts 1 in order to work with your company's existing products, it does not mean that you should not be looking to the future and learning the newer technologies that have replaced it, such as Struts 2 as Ulf suggested.

Remember that the development team in any company is the most qualified group of people to make decisions on what technology to use in their applications. So now that you know there are serious security issues with Struts 1 that are never going to be addressed, then it's up to you and your team to lead the effort to migrate to something better. As a junior developer I'm not suggesting that it's all up to you to do all this, but there's absolutely no reason why you can't have a discussion with your team about it. That kind of forward thinking should always be well received.



I'm agree with you but it just been month and i'm not able to do a single program of struts then how can i explain them about the security issues. So i think first i've to learn what is going on and when i'll get enough confidence in struts programming i should talk to my senior about the problems in struts1.

and I'm really thankful to both of you for your advice.
 
GajanaN Chalke
Greenhorn
Posts: 16
Mac Oracle Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I shudder to think of the security implications of using Struts 1 at this point. That's professionally irresponsible.

I know you're looking for a different answer, but I really think the best way to learn a framework is to, well, learn it - read some introductions, read a few tutorials, follow their example codes, and it should become clear how the different parts of a Struts app work together. http://struts.apache.org/release/1.3.x/userGuide/index.html would be an obvious starting point. There's really little point in repeating all that here.

I also think that if your company wants you to learn it, then some of the more experienced developers should help you, like the person who suggested you write this code. I think that would be a more reasonable approach than leaving a junior developer to learn on their own without any guidance (not that that would be impossible if you follow the tutorial).




I've already started learning of struts basic program from following website http://courses.coreservlets.com/Course-Materials/struts.html
is it ok to study with the given syllabus on this site?
 
Tim Cooke
Marshal
Posts: 5807
371
IntelliJ IDE Python TypeScript Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not suggesting that you can, or should, do this right away but it's something to keep in mind as you're working out the Struts 1 stuff in your application. You'll find a natural time to start talking about these things with the more senior members of your team. The fact that Struts 1 is EOL (End Of Life) should be enough reason to move on from it.
 
GajanaN Chalke
Greenhorn
Posts: 16
Mac Oracle Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:I'm not suggesting that you can, or should, do this right away but it's something to keep in mind as you're working out the Struts 1 stuff in your application. You'll find a natural time to start talking about these things with the more senior members of your team. The fact that Struts 1 is EOL (End Of Life) should be enough reason to move on from it.



I'll try at my best to tell them about this. Thank you sir.
 
Tim Cooke
Marshal
Posts: 5807
371
IntelliJ IDE Python TypeScript Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're very welcome. And welcome to the Ranch!
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic