Why Am I Getting A Null value?

[b][red]This message was edited by stricks at 2005-6-24 5:31:35[/red][/b][hr]
This is reading a file in a class named GetConfig

[code]
...
String mystr;
while ((mystr = in.readLine()) != null) {
if(mystr.equals("")){
surveyFile = in.readLine();
System.out.println(surveyFile);
}
...
[/code]

When that prints out to the console I get the path name of the file.

When I go to use that from another class...

[code]
...
GetConfig config = new GetConfig();
...
// I store that string into this string

String setup_file = config.surveyFile;
...

// Then I send it to the session. And call a jsp page

session.setAttribute("error", setup_file);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/The_Test/error.jsp");
dispatcher.forward(request, response);
[/code]

JSP page:
[code]
<%
String error = "what";
error = (String) session.getAttribute("error");

out.print(error);
%>
[/code]

null gets print out to the screen instead of the orignal string. Why?

thank you.



Comments

  • >> ...
    >> [code]
    >> // Then I send it to the session. And call a jsp page
    >>
    >> session.setAttribute("error", setup_file);
    >> RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/The_Test/error.jsp");
    >> dispatcher.forward(request, response);
    >> [/code]
    >>
    >>JSP page:
    >>[code]
    >><%
    >> String error = "what";
    >> error = (String) session.getAttribute("error");
    >>
    >> out.print(error);
    >>%>
    >>[/code]
    >>
    >> null gets print out to the screen instead of the orignal string.
    >> Why?
    >>
    >> thank you.

    Hi,
    it seems the session objects are not the same, is it possible that the JSP's session object isn't the *same* object where you set the attribute ?

    mo
  • Yeah, that's what I figured out :-P

    Thanks though!

    Strick
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion