jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeya seelan <rnjeyasee...@yahoo.co.in>
Subject Re: Cactus test case
Date Thu, 07 Feb 2008 11:43:38 GMT
Hi 
Raghunandan 
,

if you go through this site you will get answer for your question.

http://www.onjava.com/pub/a/onjava/2004/09/22/test-struts.html
 
Regards,

Jeyaseelan.A
Anadocs IT Solutions Pvt,
Adyar, Chennai-20,
Cell - 9962290394.


----- Original Message ----
From: Raghunandan B <raghunandan243@gmail.com>
To: cactus-user@jakarta.apache.org
Sent: Thursday, 7 February, 2008 12:54:05 AM
Subject: Re:Cactus test case

Hi,
How 
do 
i 
write 
cactus 
test 
case 
to 
test 
this 
servlet


import 
java.io.*;

import 
javax.servlet.http.*;
import 
javax.servlet.*;
import 
java.net.*;
import 
java.util.*;



public 
class 
SampleServlet 
extends 
HttpServlet
{

 
public 
void 
doGet(HttpServletRequest 
request,
  
  
  
  
  
  
  
  
  
  
HttpServletResponse 
response)
  
  
  
throws 
ServletException, 
IOException 
{
  
  
response.setContentType("text/html");
  
  
PrintWriter 
out 
= 
response.getWriter();
  
  
String 
title 
= 
"Session 
Tracking 
Example";
  
  
HttpSession 
session 
= 
request.getSession(true);
  
  
String 
heading;
  
  
Integer 
accessCount 
=
  
  
  
(Integer)session.getAttribute("accessCount");
  
  
if 
(accessCount 
== 
null) 
{
  
  
  
  
accessCount 
= 
new 
Integer(0);
  
  
  
  
  
  
  
} 
else 
{

  
  
  
  
accessCount 
= 
new 
Integer(accessCount.intValue() 
+ 
1);
  
  
  
}

  
  
// 
Use 
setAttribute 
instead 
of 
putValue 
in 
version 
2.2.
  
  
session.setAttribute("accessCount", 
accessCount);

  
  
out.println(
  
  
  
  
  
  
  
  
"<BODY>\n"+ 
" 
<p 
align=center>"+
  
  
  
  
"Session 
ID" 
+

  
  
  
  
  
  
  
  
 
session.getId() 
+ 
"<br>"
  
  
  
  
  
  
  
  
+
  
  
  
  
  
  
  
  
"  
Creation 
Time\n" 
+

  
  
  
  
  
  
  
  
new 
Date(session.getCreationTime()) 
+ 
"\n" 
+ 
"<br>"
  
  
  
  
  
  
  
  
+

  
  
  
  
  
  
  
  
"  
Time 
of 
Last 
Access\n" 
+

  
  
  
  
  
  
  
  
new 
Date(session.getLastAccessedTime()) 
+ 
"\n" 
+"<br>"
  
  
  
  
  
  
  
  
+

  
  
  
  
  
  
  
  
"  
Number 
of 
Previous 
Accesses\n" 
+
  
  
  
  
  
  
  
  
 
accessCount 
+ 
"\n" 
+ 
"</p>"+

  
  
  
  
  
  
  
  
"</BODY></HTML>");

  
}

  
/** 
Handle 
GET 
and 
POST 
requests 
identically. 
*/

  
public 
void 
doPost(HttpServletRequest 
request,
  
  
  
  
  
  
  
  
  
  
 
HttpServletResponse 
response)
  
  
  
throws 
ServletException, 
IOException 
{
  
  
doGet(request, 
response);
  
}
}



Regards,

Raghu




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message