Solved

JSP session & DB question.

Posted on 2001-09-18
25
288 Views
Last Modified: 2010-05-18
Hello experts,

I have used ASP in the past and I have code that I used to track webhits and record basic info into a DB. I was hoping someone could show how I could do the same with a JSP page. Can I then include this one page into each of my html pages instead of retyping it over and over again, how do I do that? I am using tomcat 3.2 for this in case it matters.

("Member") <only if they logged in>
("IPAddress")
("OperatingSystem")
("PageViewed")
("BrowserType")
("DateTimeofHit")

Then save it into my oracle DB:

Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@XXX:1521:XXX";
Connection con = DriverManager.getConnection(url, "XXX", "XXX");

0
Comment
Question by:MrError
  • 13
  • 12
25 Comments
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6492955
<%@ include file = "path" ... %>

Is used to include a repeated bit of code in your jsp files.

Let be think about the rest.
0
 

Author Comment

by:MrError
ID: 6493532
andycrofts,

Would this get the IP using JSP:

String remoteIPAddress = "";
remoteIPAddress = request.getRemoteAddr();

I have something crude for detecting the browser and OS, any idea of how to make it know the exact version of the browser? Or ways to improve this in general?

<%     // using Java, determine browser and O/S platform
     boolean isWindows = false;
     boolean isMac = false;
     boolean isNetscape = false;
     String userAgent = request.getHeader("User-Agent");

     if ( userAgent.toLowerCase().indexOf("win") >= 0 )
     {
          isWindows = true;          // Windows user
     } else
     {
          isWindows = false;          // not a Windows user
     }

     if ( userAgent.toLowerCase().indexOf("mac") >= 0 )
     {
          isMac = true;          // Apple/Mac user
     } else
     {
          isMac = false;          // not a Apple/Mac user
     }

     if ( userAgent.toLowerCase().indexOf("msie") ==-1   &&  
     userAgent.toLowerCase().indexOf("spoofer")==-1 )
     {
          isNetscape = true;     // browser is Netscape
     } else
     {
          isNetscape = false;     // browser is NOT Netscape
     }
%>

As far as setting a session for the page viewed can I do something like this:

<%session.setAttribute( "thePage", info.html ); %>
<%@ include file = "c:\interpub\wwwroot\home\into.jsp" %>
<HTML>
<BODY>
...
</BODY>
</HTML>

For getting the timestamp is there a <% getDate() %>
how can I format it for MM/DD/YYYY? How can I set that value into a session variable?
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6493624
>Would this get the IP using JSP:

>String remoteIPAddress = "";
>remoteIPAddress = request.getRemoteAddr();
Yes but beware. I have had trouble using this where browsers go through a proxy sometimes you only get the ip of the proxy

for the page viewed you could use
request.getRequestURI() and then that code remains the same to included on any page.
session.setAttribute( "thePage", request.getRequestURI() );

date you do somehing like
import java.text.* ;
DateFormat myformat = new SimpleDateFormat("MM/dd/yyyy");
String formattedDate = myformat.format(new Date());
session.setAttribute( "theDate", formattedDate);
0
 

Author Comment

by:MrError
ID: 6494333
andycrofts,

OK I will try these so far...
the only hitch is the the browser and OS detection.

as far as saving to a oracle DB and everything else:

<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.text.*"%>

<!--importing packages ends-->
<%

boolean isWindows = false;
boolean isMac = false;
boolean isNetscape = false;
String userAgent = request.getHeader("User-Agent");
String os = "";
String browser = "";

     //Test OS - how to test for unix?
     if ( userAgent.toLowerCase().indexOf("win") >= 0 )
     {// Windows user
          isWindows = true;
          os = "Windows";      
     }

     if ( userAgent.toLowerCase().indexOf("mac") >= 0 )
     {// Apple/Mac user
          isMac = true;
          os = "Mac";          
     }

     //Test Browser how to version and other browsers?
     if ( userAgent.toLowerCase().indexOf("msie") ==-1   &&  
     userAgent.toLowerCase().indexOf("spoofer")==-1 )
     {// browser is Netscape
          isNetscape = true;
          browser = "Netscape";    
     }

String IPAddress = "";
IPAddress = request.getRemoteAddr();

String thePage = ""
session.setAttribute( "thePage", request.getRequestURI() );

DateFormat myformat = new SimpleDateFormat("MM/dd/yyyy");
String formattedDate = myformat.format(new Date());
session.setAttribute( "theDate", formattedDate);

try
{
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     String url="jdbc:odbc:test";
     Connection con=DriverManager.getConnection(url, "administrator", "password");

     Statement stmt = con.createStatement();
     String query=";

     stmt.executeUpdate("insert into  tbl_hit values ("+ID+", '"+IPAddress+"','"+os+"','"+thePage+"','"+Browser+"','"+theDate+"')");
     con.commit();

}
catch (Exception e) {}

%>
0
 

Author Comment

by:MrError
ID: 6494389
one note I tried my above code it has some problems. Like this:

DateFormat myformat = new SimpleDateFormat("MM/dd/yyyy");
String formattedDate = myformat.format(new Date());<--error
session.setAttribute( "theDate", formattedDate);

new Date did not work?
0
 

Author Comment

by:MrError
ID: 6494453
ok Now in the DB part I have had partial sucess:

try
{
     Class.forName("oracle.jdbc.driver.OracleDriver");
     String url = "jdbc:oracle:thin:@xxx:1521:yyy";
     Connection con = DriverManager.getConnection(url, "vvv", "zzz");
     Statement stmt = con.createStatement();
     String query="";

     stmt.executeUpdate("insert into  tbl_hit values ("+ID+",'"+MemID+"','"+IPAddress+"','"+os+"','"+thePage+"','"+browser+"','"+theDate+"')");
     con.commit();

}
catch (Exception e) {}

this compiled and ran with no error but the data did not get saved into the Database? What went wrong? I used a commit(); even?
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6495971
What goes wrong with the new Date()? What error?

I can't spot anything wrong in your db bit. No error message?

0
 

Author Comment

by:MrError
ID: 6496208
One error in date is like this:

org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080\_0002ftest_0002ejsptest_jsp_2.java:117: Ambiguous class: java.util.Date and java.sql.Date
String formattedDate = myformat.format(new Date());
                                           ^

IS this because I have not imported the needed class?

<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.text.*"%>

as far as the DB part:

try
{
     Class.forName("oracle.jdbc.driver.OracleDriver");
     String url = "jdbc:oracle:thin:@xxx:1521:xxx";
     Connection con = DriverManager.getConnection(url, "xxx", "xxx");
     Statement stmt = con.createStatement();
     String query="";

     stmt.executeUpdate("insert into  tbl_hit values ("+ID+",'"+MemID+"','"+IPAddress+"','"+os+"','"+thePage+"','"+browser+"','"+theDate+"')");
     con.commit();
     //should a con.commit(); do the job?
     //should I also do
     con.close();
     stmt.close();
}
catch (Exception e) {}

No SQL errors it seems to run and everything just does not commit the data to the Oracle table.
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6496241
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080\_0002ftest_0002ejsptest_jsp_2.java:117:
Ambiguous class: java.util.Date and java.sql.Date
String formattedDate = myformat.format(new Date());
                                          ^

IS this because I have not imported the needed class?

**************
It is because you have imported both java.util.* and java.sql.* and they both have Date() classes

String formattedDate = myformat.format(new java.util.Date());
Should fix it.
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6496260
Db bit

perhaps if you did

String sql = ("insert into  tbl_hit values ("+ID+",'"+MemID+"','"+IPAddress+"','"+os+"','"+thePage+"','"+browser+"','"+theDate+"')";

System.out.println(sql);

stmt.executeUpdate(sql);

Then check the output from System.out.println(sql); to see if the sql statement is ok and even cut and paste into the oracle "query analyser" (thats waht its called in mssql) to see if the sql does work.

0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6496368
Below is a simple jsp that connects to a database (MSSQL), adds a record to ther table then displays the contents of the table.
Hope something in here helps with your db problem.

<html>
<body>

<%@ page import="java.sql.*" %>

<%
  int andy = 0;
  String sql = "";
  Connection con = null;
  Statement stmt = null;
  ResultSet rset = null;

  try
  {
    // fill in db_name, user_id and user_pass
    String db_name   = "test";
    String url       = "jdbc:inetdae:becontree:1433?database=test&sql7=true";
    String user_id   = "sa";
    String user_pass = "";

    // setup the driver
    Class.forName("com.inet.tds.TdsDriver").newInstance();
    con = DriverManager.getConnection(url, user_id, user_pass);
    con.setAutoCommit(true);


    // setup the query
    sql = "insert into test values('some text')";
    stmt = con.createStatement();
    andy = stmt.executeUpdate(sql);

    sql = "select * from test";
    rset = stmt.executeQuery(sql);

  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
  con.close();
%>
<br>
<br>
<br>
<h1>Database Test</h1>
<br>
<br>
<%
while (rset.next())
{
%>
     <%=rset.getString("field1") %>
     <br>
<%
}
%>
</html>
</body>

0
 

Author Comment

by:MrError
ID: 6498518
andycrofts,

The Date idea was good you are correct needed to specify the library exactly... The problem lies in the date format I believe. Oracle wants DD/MON/YYYY. how to set it this way well it did not like:
DateFormat myformat = new SimpleDateFormat("dd/MON/yyyy");

I tried this:
DateFormat myformat = new SimpleDateFormat("dd/mmm/yyyy");

the output was:
insert into  tbl_hit values (2,'3','24.164.6.120','Windows','','','09/17/2001') <--date format is still wrong?


I look at this Date it can have:
int year,int month,int date, int hrs,int min,int sec

How do I set it to have DD/MON/YYYY HR.MN.SEC?

Once the Date issue is fixed I think this will work.
String sql = "insert into  tbl_hit values ("+ID+",'"+MemID+"','"+IPAddress+"','"+os+"','"+thePage+"','"+browser+"','"+theDate+"')";

Thank you for being so helpful!!!

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6499176
Below are the pattern characters. If by MON you mean the month name then you want MMM. M="9" MM="09" MMM="Sep" MMMM="September"

>I tried this:
>DateFormat myformat = new SimpleDateFormat("dd/mmm/yyyy");
This is wrong as lowercase m is minutes where uc M is month.

 Symbol   Meaning                 Presentation        Example
 ------   -------                 ------------        -------
 G        era designator          (Text)              AD
 y        year                    (Number)            1996
 M        month in year           (Text & Number)     July & 07
 d        day in month            (Number)            10
 h        hour in am/pm (1~12)    (Number)            12
 H        hour in day (0~23)      (Number)            0
 m        minute in hour          (Number)            30
 s        second in minute        (Number)            55
 S        millisecond             (Number)            978
 E        day in week             (Text)              Tuesday
 D        day in year             (Number)            189
 F        day of week in month    (Number)            2 (2nd Wed in July)
 w        week in year            (Number)            27
 W        week in month           (Number)            2
 a        am/pm marker            (Text)              PM
 k        hour in day (1~24)      (Number)            24
 K        hour in am/pm (0~11)    (Number)            0
 z        time zone               (Text)              Pacific Standard Time
 '        escape for text         (Delimiter)
 ''       single quote            (Literal)           '
 
Format Pattern                         Result
 --------------                         -------
 "yyyy.MM.dd G 'at' hh:mm:ss z"    ->>  1996.07.10 AD at 15:08:56 PDT
 "EEE, MMM d, ''yy"                ->>  Wed, July 10, '96
 "h:mm a"                          ->>  12:08 PM
 "hh 'o''clock' a, zzzz"           ->>  12 o'clock PM, Pacific Daylight Time
 "K:mm a, z"                       ->>  0:00 PM, PST
 "yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM
 
0
 

Author Comment

by:MrError
ID: 6499261
Things are starting to work. There are only two hangups left thePage and still that annoying theDate

as you can see I did this:
String theDate = "";
DateFormat myformat = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss z");
String formattedDate = myformat.format(new java.util.Date());
session.setAttribute( "theDate", formattedDate);

When it inserts the date time it is null?

As for the thePage it is null as well.
String thePage = "";
session.setAttribute( "thePage", request.getRequestURI() );

the complete test.jsp

<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.text.*"%>

<!--importing packages ends-->
<%

boolean isWindows = false;
boolean isMac = false;
boolean isNetscape = false;
String userAgent = request.getHeader("User-Agent");
String os = "";
String browser = "";

     //Test OS - how to test for unix?
     if ( userAgent.toLowerCase().indexOf("win") >= 0 )
     {// Windows user
          isWindows = true;
          os = "Windows";      
     }

     if ( userAgent.toLowerCase().indexOf("mac") >= 0 )
     {// Apple/Mac user
          isMac = true;
          os = "Mac";          
     }

     //Test Browser how to version and other browsers?
     if ( userAgent.toLowerCase().indexOf("msie") ==-1   &&  
     userAgent.toLowerCase().indexOf("spoofer")==-1 )
     {// browser is Netscape
          isNetscape = true;
          browser = "Netscape";    
     }

String MemID = "";
int curID = 0;
int upID = 0;

String IPAddress = "";
IPAddress = request.getRemoteAddr();

String thePage = "";
session.setAttribute( "thePage", request.getRequestURI() );

String theDate = "";
DateFormat myformat = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss z");
String formattedDate = myformat.format(new java.util.Date());
session.setAttribute( "theDate", formattedDate);


ResultSet rset = null;
ResultSet rs = null;

try
{
     Class.forName("oracle.jdbc.driver.OracleDriver");
     String url = "jdbc:oracle:thin:@xxx:1521:xxx";
     Connection con = DriverManager.getConnection(url, "xxx", "xxx");
     Statement stmt = con.createStatement();
     Statement stmt2 = con.createStatement();
     Statement stmt3 = con.createStatement();
     con.setAutoCommit(true);


     String sql = "Select ID from tbl_Nos where Gen = 'hit' ";
     rs = stmt.executeQuery(sql);
     while(rs.next())
     {
          curID = rs.getInt(1);
          upID = curID + 1;
          stmt.executeUpdate("Update TBL_Nos SET ID='"+upID+"' where GEN='hit' ");
     }


     sql = "insert into  tbl_hit values ("+curID+",'"+MemID+"','"+IPAddress+"','"+os+"','"+thePage+"','"+browser+"','"+theDate+"')";
     
     System.out.println(sql);
     stmt2.executeUpdate(sql);

     // test for the record.
     sql="Select * from tbl_hit";
     rset = stmt3.executeQuery(sql);
     
}
catch (Exception e) {e.printStackTrace();}


%>

<HTML>
<Body>

<P>Test worked</P>

<br>
<br>
<br>
<h1>Database Test</h1>
<br>
<br>
<%
     while (rset.next())
     {
%>
          <%=rset.getString("ID") %>
          <%=rset.getString("OS") %>
          <%=rset.getString("IP") %>
<br>
<%
     }
%>

</Body>
</HTML>
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6499305
Why are you using session.setAttribute( "thePage", request.getRequestURI() ); ?

I am not sure you really want to bother doing this. This stores values in attributes within the implicit session object and can be accessed using the session.getAttribute method.
In your jsp you are doing String thePage = ""; but never assigning anything else into it before  sql = "insert into  tbl_hit values ("+curID+",'"+MemID+"','"+IPAddress+"','"+os+"','"+thePage+"','"+browser+"','"+theDate+"')";.

I think you probably want
thePage = request.getRequestURI();
rather than
session.setAttribute( "thePage", request.getRequestURI() );

...and likewise for theDate.
Maybe you want both if you plan to access these attributes from the session object from other pages.
HTH
0
 

Author Comment

by:MrError
ID: 6500598
andycrofts,

For the date now you said to follow the same pattern as thePage:

String theDate = "";
DateFormat myformat = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss z");
String formattedDate = myformat.format(new java.util.Date());
session.setAttribute( "theDate", formattedDate);

I tried messing with this but every time I tried to take theDate and put a String cast to it, this did not work. How does one put a Date with the correct MMM format into a string?
0
 
LVL 13

Accepted Solution

by:
Philip Pinnell earned 100 total points
ID: 6504952
I am not sure I understand. At the bottom is a jsp that works for me.
Note the variable "theDate" from 'String theDate="";'
has nothing whatsoever to do with the session attribute "theDate" which is an attribute of the implicit session object and can be access by the method "getAttribute" of the session object.



*******************************************************************
<%@ page import = "java.util.Date" %>
<%@ page import = "java.text.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
    <title>Date Test</title>
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
</HEAD>

<BODY>
<%
DateFormat myDate = new SimpleDateFormat(" EE dd/MMM/yyyy h:mm a zz");
String andy = myDate.format(new Date());

DateFormat myformat = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss z");
String formattedDate = myformat.format(new java.util.Date());
session.setAttribute( "theDate", formattedDate);

%>
<h1> Date Test </h1>
<br>
<br>
<h2>
<%=andy %>
<br>
<br>
<%=session.getAttribute("theDate") %>
</h1>
<br>
<br>
</body>
</html>
0
 

Author Comment

by:MrError
ID: 6505731
I agree your code works however when I try and incorporate it with a Oracle insert it fails every way I have tried so far.

java.lang.NullPointerException:

String IPAddress = "";
IPAddress = request.getRemoteAddr();

String thePage = "";
thePage = request.getRequestURI();

DateFormat myDate = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss");
String y = myDate.format(new java.util.Date());

ResultSet rset = null;
ResultSet rs = null;

try
{
     Class.forName("oracle.jdbc.driver.OracleDriver");
     String url = "jdbc:oracle:thin:@xxx:1521:xxx";
     Connection con = DriverManager.getConnection(url, "xxx", "xxx");
     Statement stmt = con.createStatement();
     Statement stmt2 = con.createStatement();
     Statement stmt3 = con.createStatement();
     con.setAutoCommit(true);


     String sql = "Select ID from tbl_Nos where Gen = 'hit' ";
     rs = stmt.executeQuery(sql);
     while(rs.next())
     {
          curID = rs.getInt(1);
          upID = curID + 1;
          stmt.executeUpdate("Update TBL_Nos SET ID='"+upID+"' where GEN='hit' ");
     }


     sql = "insert into  tbl_hit values ("+curID+",'"+MemID+"','"+IPAddress+"','"+os+"','"+thePage+"','"+browser+"','"+y+"')";
     
     System.out.println(sql);
     stmt2.executeUpdate(sql);

     // test for the record.
     sql="Select * from tbl_hit";
     rset = stmt3.executeQuery(sql);
     
}
catch (Exception e) {e.printStackTrace();}
0
 

Author Comment

by:MrError
ID: 6505773
Maybe I should modify my Oracle table to use a varchar2 for date inserted instead of the Date type I am currently using? Then I think everything will work.
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6505805
In a slightly modified version of what you are doing "println(sql)" gives me
insert into  tbl_hit values (curID,'memID','192.168.0.88','os','/monument/datetest2.jsp','browser','24/Sep/2001 02:36:48')

Now it looks an ok string to me but I have no idea what oracle is expecting.
I can't see why you should get a null pointer exception.

If you cut and paste the println sql output does this work with oracle directly?
0
 

Author Comment

by:MrError
ID: 6507104
This is what I get as far as the sql string and this fails:

insert into  tbl_hit2 values (35,'','24.163.166.120','Windows','/test3.jsp','','24/Sep/2001 04:37:38')

Here is the error:

java.sql.SQLException: ORA-01830: date format picture ends before converting entire input string

here is the table:

CREATE TABLE TBL_HIT2 (
  ID          NUMBER        NOT NULL,
  MEMID       VARCHAR2 (7),
  IP          VARCHAR2 (15),
  OS          VARCHAR2 (20),
  PAGE        VARCHAR2 (20),
  BROWSER     VARCHAR2 (20),
  DATEINSERT  DATE);

this however does work:

insert into  tbl_hit2 values (35,'','24.163.166.120','Windows','/test3.jsp','','24/Sep/2001')
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6508336
When you say this
insert into  tbl_hit2 values (35,'','24.163.166.120','Windows','/test3.jsp','','24/Sep/2001')
works, I take it you mean if you execute this command through the oracle front end it works.

So if you use
DateFormat myDate = new SimpleDateFormat("dd/MMM/yyyy");
String y = myDate.format(new java.util.Date());

In your jsp does it not work?

Another thought, does oracle expect tenths of seconds?
0
 

Author Comment

by:MrError
ID: 6508972
When you say this
insert into  tbl_hit2 values (35,'','24.163.166.120','Windows','/test3.jsp','','24/Sep/2001')
works, I take it you mean if you execute this command through the oracle front end it works.

Yes... I entered this from the SQL output that the println gives tomcat and then go into orcale and it inserts fine.

=========================================
DateFormat myDate = new SimpleDateFormat("dd/MMM/yyyy");
String y = myDate.format(new java.util.Date());

In your jsp does it not work? No, it does work. It does not work when I add hours, minutes and seconds. Tenths of a second I have not tried. however I have two tables now one with date datatype and one with a varchar2 date. The Date one has problems with hh:mm:ss but the varchar2 is working fine.

I am thinking I will be fine using varchar2 for now but I have other hanging questions.
=========================================
one question about includes. When I include a reference to this jsp, I go like this:

<%@ include file="test.jsp"%>

Does this include execute the test.jsp page? That is the behavior I am hoping for because then I have a basic web hit tracker using jsp.
=========================================
last this detection of OS and browser:

I found this code a while ago it seems to sort of work.
if ( userAgent.toLowerCase().indexOf("win") >= 0 )
{// Windows user
     isWindows = true;
     os = "Windows";      
}

//Test Browser how to version and other browsers?
if ( userAgent.toLowerCase().indexOf("msie") ==-1   &&  
userAgent.toLowerCase().indexOf("spoofer")==-1 )
{
     isNetscape = true;
     browser = "Netscape";    
}

What is userAgent? How many different values can it have? I am not sure of what this if statement does really. Is it saying if the lower case index is "msie" is equal to -1 and it also has an index of "spoofer" that is equal to -1 then do something. That just seems odd that is even works.
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 6509066
Your database problem seems to be an oracle problem for which I don't think I can help. Good luck.

<%@ include file = "path" ... %>

This combines the content of the main jsp with the "included" file before parsing the jsp code and building the page servlet. Your "included" file can there fore been anything ( HTML, JavaScript, text, jsp, java) as long as when inserted into the main jsp correct syntax is maintained.

Beware. Although the servlet container will detect updates to a jsp file and rebuild the page servlet, it will not detect that an included file has been modified and rebuild it as part of its parent jsp. Whenever modifying an included file, touch or modify its parent. Or delete the page servlet .class files.

Lastly, I am not sure of all the possible values are that can be returned. It depends on whether you want IE vs any other browser and windows vs any other OS or more detail. Your mathod seems ok as far as it goes.
Check this link.
http://stardeveloper.com:8080/articles/072201-2.shtml

0
 

Author Comment

by:MrError
ID: 6509869
ok so this is what I need to do:
<%@ include file="test.jsp"%>

ok, by entering this line it execute that jsp so that is good.

The link was good. I wonder how I can detect even more details but I will look around.

You have been extremely helpful! thank you.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now