In my web application I have to write the URL of the web application and specify the home.jsp
page that I want to be the home page, I want to know how I can access the the application in the browser just by typing the project's root folder
name.
I have set the welcome-file-list
in web.xml
to the home.jsp
that I want to get to every time I access the application, but it is not helping. Probably because I am using Struts 2 framework, If it is possible should I set the welcome-file-list
in struts.xml
? How do I do it?
Another question, I have so far. For example in the execute
method of one action
class,
I want two different results SUCCESS
or ERROR
, as
if(message.getMessageBody() != null &&
message.getMessageDestinationEmail() != null &&
message.getMessageHead() != null){
return SUCCESS;
} else
return ERROR;
I mapped the error to error.jsp
page and success to a different .jsp
page in struts.xml
as
<action name="message" class="com.mule.basik.action.PostOfficeAction"
method="execute">
<result name="success">/status.jsp</result>
<result name="error">/error.jsp</result>
</action>
But whether (in the browser form) I fill in the messageHead
messageBody
or not the success
page (/status.jsp
) is returned.
I am not sure how(when) struts2 instantiates the objects
members of an ActionClass
, so I decided to declare a non parameter constructor
that instantiates the bean message
(member of the action class) because I thought for every request an instance of the action class is created and thus there is a new instance of the beans
the action class has (depends on). But it didn't help anything, what am I doing wrong? I guess I should try to use Log4j and print something in execute method before the return SUCCESS
and before return ERROR
to determine if the if
statement is evaluating to true
or false
, but even if I find that it is evaluating to true
when inputs are entered or not , I still don't understand what I will have to do next, to make the execute return ERROR
beside testing as I showed above.