Link to home
Start Free TrialLog in
Avatar of jason101799
jason101799

asked on

Include file problem!!

Experts,

I need advice from you guyz and gals. I have included the codes for your reference.

Test.jsp
--------

<%@ include file="chk_session.jsp" %>
<%@ page language="java" %>
<%@ page import="java.util.*, java.sql.*, javax.servlet.*, javax.servlet.http.*"
%>
<html>                                                    <head>                                                    <title>Verify User Profile</title>                                           </head>                                                   <body>                                                    <center>                                                  <IMG SRC=/images/wsisupport/webshipping.gif height=100>                        
<HR>                                                      </center>                                                 </body>
</html>                      

----------------------------------------------------------

chk_session.jsp
---------------
<%@ page language="java";
 HttpSession session = request.getSession(true);%>
<%out.println("out=" + session.getMaxInactiveInterval()/60);%>

----------------------------------------------------------

I have included the chk_session.jsp page in my test.jsp page. But when I point to the test.jsp page, the out.println statement did not print out the session getMaxInactiveInterval. I wonder what went wrong, please advice.

Cheers
Jason
Avatar of mohan_sekar
mohan_sekar
Flag of United States of America image

Hi,


   check whether your chk_session.jsp is correctly in your application's path

bye
Avatar of jason101799
jason101799

ASKER

Mohan,

Both are located in the same directory. Will there be any problem? Thanks
The code you posted doesn't compile under Tomcat. I took the liberty of modifying it.

----------------------------------------------------------
Test.jsp

<%@ include file="chk_session.jsp" %>
<%@ page language="java" %>
<%@ page import="java.util.*, java.sql.*, javax.servlet.*, javax.servlet.http.*" %>
<html>
   <head>                                      
      <title>Verify User Profile</title>                                          
   </head>
   <body>                                              
      <center>  
         <IMG SRC=/images/wsisupport/webshipping.gif height=100>
      </center>                                                    
   </body>
</html>


----------------------------------------------------------

chk_session.jsp

<% out.println("out=" + session.getMaxInactiveInterval()/60);%>

----------------------------------------------------------

There were several problems with this:

1) You can't have the page directive twice in a given JSP page. When you included chk_session.jsp, you had a page directive in both files, so the JSP compier barfed.

2) The session object is created by default. You don't need to create one by hand.

This seemed to work on my machine...

--Steve
Steve,

I have used your code but it did not print out the text for the include file. I have copied exactly from the comment page but it fails.

Any idea why??


Cheers
Jason
That's odd. What  do you see on the page?

For me, I get a line which says "out=30" and a blank image holder.

What JSP container are you using? I'm using the most recent Tomcat.

What browser are you using?

I've run with both IE 5.00 on a Windows box and Netscape 6.01 on a Linux box. They both work.

It sounds as if you have a configuration problem in your JSP container...

Hmm...

--Steve
Steve,

Sorry for my ignorance but I am totally new to "JSP Container". I am using Netscape Server Enterprise 4. Where should I start degugging? By the way I manage to see the image displayed and nothing else.

Cheers
Jason
One really stupid question for you.

I noticed in your original post that you called your first JSP Test.jsp yet you refer to loading test.jsp later in the post.

Is it possible that you have two copies laying around? One called Test.jsp and the other test.jsp and you're just loading the wrong one?

I'm not trying to be insulting here, I just can't see how this could fail without some error message being plainly visible in your browser...

--Steve
Steve,

Typo errors and I am sure about it. :)
Any clue about this issue?

Cheers
I've not used Netscape Server, but it shouldn't be much different...

Some things to try:

1) Clean out your browser's cache. Perhaps you're getting cached versions, and not the one you think you're getting.

2) Rename the chk_session.jsp to session.jsp then touch the Test.jsp file to force a recompile. Now when you load the page, you'd better see some sort of compilation error saying that chk_session.jsp is not found. This will tell us whether you're actually getting the JSP file compiled.

3) Rename the session.jsp back to chk_session.jsp and touch the Test.jsp file again. Move the include statement so that it is between the HTML tags. Maybe your browser doesn't like the fact that the data gets printed outside of the HTML page.

Try these and lets see what happens. If this doesn't give us some more info, I'm gonna have to wrack my brain to see what else to try.

--Steve
Steve,

I have tried your advice but it seems that the problem still persist. Is there any configuration that I need to do at the Netscape server side?

Cheers
Steve,

I have tried your advice but it seems that the problem still persist. Is there any configuration that I need to do at the Netscape server side?

Cheers
ASKER CERTIFIED SOLUTION
Avatar of sdussinger
sdussinger

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Admin notified of User neglect. Force-accepted by
Netminder
Community Support Moderator
Experts Exchange