By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,637 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,637 IT Pros & Developers. It's quick & easy.

Getting Property file values in welcome page of web application

madhoriya22
100+
P: 252
Hi,
This is the code of the entrypage of my web application.
Expand|Select|Wrap|Line Numbers
  1. <%@page contentType="text/html"%>
  2. <%@page pageEncoding="UTF-8"%>
  3. <%@page import="com.spi.defecttracker.vo.PropertiesVO"%>
  4. <%@page session="true" %>
  5. <html>
  6. <head>
  7.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8.     <title>JSP Page</title>
  9. </head>
  10. <body>
  11. <%
  12. PropertiesVO urlProperty = (PropertiesVO)session.getAttribute("URLPropertiesList");
  13. System.out.println("host:\t"+urlProperty.getHost()+"\tPort:\t"+urlProperty.getPort());
  14. %>
  15. <form method="POST" action="http://<%=urlProperty.getHost()%>:<%=urlProperty.getPort()%>/DefectTracker/RequestHandler">
  16.     Click Here To Access Defect Tracker&nbsp;
  17.     <input type="submit" value="Start Defect Tracker" >
  18.     </p>
  19.     <input type="hidden" name="SCREEN_ID" value="0" />
  20. </form>
  21. </body>
  22. </html>
  23.  
  24.  
Previously this file was a .html file. But to change the url in all the files what I did ....... I am getting the url properties from the Properties file. Now this thing is working in all the jsp file except this welcome jsp file. It is throwing NullPointerException and host and port values are not coming.

I am setting the propertyVO object in session after execution of this entry page. How should I make it work.
Need ur help !
Sep 6 '07 #1
Share this Question
Share on Google+
7 Replies


10K+
P: 13,264
Hi,
This is the code of the entrypage of my web application.
Expand|Select|Wrap|Line Numbers
  1. <%@page contentType="text/html"%>
  2. <%@page pageEncoding="UTF-8"%>
  3. <%@page import="com.spi.defecttracker.vo.PropertiesVO"%>
  4. <%@page session="true" %>
  5. <html>
  6. <head>
  7.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8.     <title>JSP Page</title>
  9. </head>
  10. <body>
  11. <%
  12. PropertiesVO urlProperty = (PropertiesVO)session.getAttribute("URLPropertiesList");
  13. System.out.println("host:\t"+urlProperty.getHost()+"\tPort:\t"+urlProperty.getPort());
  14. %>
  15. <form method="POST" action="http://<%=urlProperty.getHost()%>:<%=urlProperty.getPort()%>/DefectTracker/RequestHandler">
  16.     Click Here To Access Defect Tracker&nbsp;
  17.     <input type="submit" value="Start Defect Tracker" >
  18.     </p>
  19.     <input type="hidden" name="SCREEN_ID" value="0" />
  20. </form>
  21. </body>
  22. </html>
  23.  
  24.  
Previously this file was a .html file. But to change the url in all the files what I did ....... I am getting the url properties from the Properties file. Now this thing is working in all the jsp file except this welcome jsp file. It is throwing NullPointerException and host and port values are not coming.

I am setting the propertyVO object in session after execution of this entry page. How should I make it work.
Need ur help !
Pinpoint the line(s) throwing the exception (println) and just don't do whatever it is if urlProperty is null.

Something like
Expand|Select|Wrap|Line Numbers
  1. String host = "";
  2. String port = "";
  3. PropertiesVO urlProperty = (PropertiesVO)session.getAttribute("URLPropertiesList");
  4. if(urlProperty != null) {
  5.      host = urlProperty.getHost();
  6.      port =  urlProperty.getPort();
  7. }
Sep 6 '07 #2

madhoriya22
100+
P: 252
Pinpoint the line(s) throwing the exception (println) and just don't do whatever it is if urlProperty is null.

Something like
Expand|Select|Wrap|Line Numbers
  1. String host = "";
  2. String port = "";
  3. PropertiesVO urlProperty = (PropertiesVO)session.getAttribute("URLPropertiesList");
  4. if(urlProperty != null) {
  5. host = urlProperty.getHost();
  6. port = urlProperty.getPort();
  7. }
Hi,
Actually this is entry page of application. After execution of this page I am setting the propertyVO object in the session. Thats why these host and port values are not coming to this page and thats why it is throwing exception.
What I need is to set this object in the session before the execution of this entry page.
Sep 6 '07 #3

10K+
P: 13,264
Hi,
Actually this is entry page of application. After execution of this page I am setting the propertyVO object in the session. Thats why these host and port values are not coming to this page and thats why it is throwing exception.
What I need is to set this object in the session before the execution of this entry page.
Well then set the properties as soon that page is entered.
Instead of getting the properties just set them in the session.
Sep 6 '07 #4

madhoriya22
100+
P: 252
Well then set the properties as soon that page is entered.
Instead of getting the properties just set them in the session.
Hi,
That is the problem.. I dont know how to set properties in the session as soon as that page is entered. Remember that page is verty first page of the appl. and it is a welcome file also ..
Expand|Select|Wrap|Line Numbers
  1.  
  2. <welcome-file>
  3.          EntryPage.jsp
  4. </welcome-file>
  5.  
Sep 6 '07 #5

10K+
P: 13,264
Hi,
That is the problem.. I dont know how to set properties in the session as soon as that page is entered. Remember that page is verty first page of the appl. and it is a welcome file also ..
Expand|Select|Wrap|Line Numbers
  1.  
  2. <welcome-file>
  3.          EntryPage.jsp
  4. </welcome-file>
  5.  
How were you setting it after that first page?
Sep 6 '07 #6

madhoriya22
100+
P: 252
How were you setting it after that first page?
Hi,
After pressing button on that first page the control goes to the requesthandler serlvet. In servlet based on screen Id of the first page a function is called. In that function I am setting all the session attributes.
Sep 6 '07 #7

10K+
P: 13,264
Hi,
After pressing button on that first page the control goes to the requesthandler serlvet. In servlet based on screen Id of the first page a function is called. In that function I am setting all the session attributes.
So create the properties object in the first JSP instead or don't try to access it in that JSP if you don't want to create it there or maybe I'm missing something here ...
Sep 6 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.