Getting Property file values in welcome page of web application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhoriya22
    Contributor
    • Jul 2007
    • 251

    Getting Property file values in welcome page of web application

    Hi,
    This is the code of the entrypage of my web application.
    Code:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="com.spi.defecttracker.vo.PropertiesVO"%>
    <%@page session="true" %>
    <html>
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    	<title>JSP Page</title>
    </head>
    <body>
    <%
    PropertiesVO urlProperty = (PropertiesVO)session.getAttribute("URLPropertiesList");
    System.out.println("host:\t"+urlProperty.getHost()+"\tPort:\t"+urlProperty.getPort());
    %>
    <form method="POST" action="[url="http://<%=urlproperty.gethost()%>:<%=urlProperty.getPort()%>/DefectTracker/RequestHandler"]http://<%=urlProperty.getHost()%>:<%=urlProperty.getPort()%>/DefectTracker/RequestHandler[/url]">
    	Click Here To Access Defect Tracker&nbsp;
    	<input type="submit" value="Start Defect Tracker" >
    	</p>
    	<input type="hidden" name="SCREEN_ID" value="0" />
    </form>
    </body>
    </html>
    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 NullPointerExce ption 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 !
    Last edited by madhoriya22; Sep 6 '07, 07:09 AM. Reason: Adding more details.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by madhoriya22
    Hi,
    This is the code of the entrypage of my web application.
    Code:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="com.spi.defecttracker.vo.PropertiesVO"%>
    <%@page session="true" %>
    <html>
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    	<title>JSP Page</title>
    </head>
    <body>
    <%
    PropertiesVO urlProperty = (PropertiesVO)session.getAttribute("URLPropertiesList");
    System.out.println("host:\t"+urlProperty.getHost()+"\tPort:\t"+urlProperty.getPort());
    %>
    <form method="POST" action="[url="http://%3C%=urlproperty.gethost%28%29%%3E:%3C%=urlProperty.getPort%28%29%%3E/DefectTracker/RequestHandler"]http://<%=urlProperty.getHost()%>:<%=urlProperty.getPort()%>/DefectTracker/RequestHandler[/url]">
    	Click Here To Access Defect Tracker&nbsp;
    	<input type="submit" value="Start Defect Tracker" >
    	</p>
    	<input type="hidden" name="SCREEN_ID" value="0" />
    </form>
    </body>
    </html>
    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 NullPointerExce ption 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
    [CODE=java]String host = "";
    String port = "";
    PropertiesVO urlProperty = (PropertiesVO)s ession.getAttri bute("URLProper tiesList");
    if(urlProperty != null) {
    host = urlProperty.get Host();
    port = urlProperty.get Port();
    }[/CODE]

    Comment

    • madhoriya22
      Contributor
      • Jul 2007
      • 251

      #3
      Originally posted by r035198x
      Pinpoint the line(s) throwing the exception (println) and just don't do whatever it is if urlProperty is null.

      Something like
      [CODE=java]String host = "";
      String port = "";
      PropertiesVO urlProperty = (PropertiesVO)s ession.getAttri bute("URLProper tiesList");
      if(urlProperty != null) {
      host = urlProperty.get Host();
      port = urlProperty.get Port();
      }[/CODE]
      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.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by madhoriya22
        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.

        Comment

        • madhoriya22
          Contributor
          • Jul 2007
          • 251

          #5
          Originally posted by r035198x
          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 ..
          Code:
           
          <welcome-file>
          		 EntryPage.jsp
          </welcome-file>
          Last edited by madhoriya22; Sep 6 '07, 10:30 AM. Reason: To add my signature :)

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by madhoriya22
            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 ..
            Code:
             
            <welcome-file>
            		 EntryPage.jsp
            </welcome-file>
            How were you setting it after that first page?

            Comment

            • madhoriya22
              Contributor
              • Jul 2007
              • 251

              #7
              Originally posted by r035198x
              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.
              Last edited by madhoriya22; Sep 6 '07, 12:13 PM. Reason: To add my signature :)

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by madhoriya22
                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 ...

                Comment

                Working...