Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: mwvisa1Posted on 2009-10-13 at 17:22:52ID: 25566151
jandersonwidener,
ng> jectpackag e.MVC_view .ViewDefin ition" />
tAttribute ("viewDefi nition"); strong>
kage.contr oller.Cont rolServlet .
ong> "
ication, but in mine I took in the InputStream with the XML you supplied and converted that to a string I stored in an instance variable called "message" on a new MailNotificaiton instance and then returned the instance.
ition ipview</strong>) {
();
tAttribute ("viewDefi nition"); trong>notif ication.ge tMessage(i pview))</st rong>
Since you are storing the bean in the "request" scope :
<jsp:useBean
id="viewDefinition" <strong>scope="request"</stro
class="mytld.mycompany.pro
It will have to be accessed as such in the servlet :
<strong>
ViewDefinition ipview = (ViewDefinition)request.ge
</
To ensure that the request object was carried from the JSP page to the Servlet page I used :
<jsp:forward page="./ControlServlet" />
Where /ControlServlet is the url-pattern mapped to my version of mytld.mycompany.projectpac
Also (just in case since you only show getProperty above), I set the property of my bean as such :
<jsp:<strong>setProperty</str
name="viewDefinition" property="sessionIPAddress
<strong>value="<%= request.getRemoteAddr() %>"</strong> />
I am not sure of your implementation of MailNotification.loadNotif
Now in my servlet I have an instance of MailNotification. This is probably not what you want to do totally, but hopefully it gives you the idea of what I am suggesting here -- which is to read the ViewDefinition from HttpRequest in Servlet and then pass it to the MailNotification object somehow -- I chose to do it through getMessage().
public String getMessage(<strong>ViewDefin
String reapIP = ipview.getSessionIPAddress
String text = message; // <-- message was loaded via xml.
// note fix to replace call.
<strong>
text = text.replace(IP_PATTERN, reapIP);
</strong>
return text;
}
So putting this together in the servlet, I did :
ViewDefinition ipview = (ViewDefinition)request.ge
<s
If anything is unclear OR you still can't get this to work in your environment, please share the code for JSP that you are using to set the IP address in the first place and how you are passing to the servlet.
Also show the rest of the servlet code where you are reading the bean again. You had this in the MailNotification class which will probably not work that way. You can try it from a different scope like application OR session, but request would require the HttpRequest object in order to read the bean from so another alternative would be to pass that to the getMessage() function instead of ViewDefinition.
Hope that helps.
--isa