You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2002/08/31 01:15:48 UTC
cvs commit: jakarta-cactus/sample-servlet/src/sample/share/org/apache/cactus/sample SampleServlet.java
vmassol 2002/08/30 16:15:48
Modified: sample-servlet/src/sample/share/org/apache/cactus/sample
SampleServlet.java
Log:
new coding conventions
Revision Changes Path
1.2 +37 -17 jakarta-cactus/sample-servlet/src/sample/share/org/apache/cactus/sample/SampleServlet.java
Index: SampleServlet.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/sample-servlet/src/sample/share/org/apache/cactus/sample/SampleServlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SampleServlet.java 10 Mar 2002 14:26:04 -0000 1.1
+++ SampleServlet.java 30 Aug 2002 23:15:48 -0000 1.2
@@ -55,7 +55,9 @@
import java.io.IOException;
import java.io.PrintWriter;
+
import java.util.Hashtable;
+
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -84,8 +86,10 @@
*
* @param theRequest the HTTP request
* @param theResponse the HTTP response
+ *
+ * @exception IOException on failure
*/
- public void doGet(HttpServletRequest theRequest,
+ public void doGet(HttpServletRequest theRequest,
HttpServletResponse theResponse) throws IOException
{
PrintWriter pw = theResponse.getWriter();
@@ -96,7 +100,6 @@
// (like Tomcat 3.2) add some characters at the end of the line
// ('\x0D' + '\x0A') even though we use the print() method and not
// println() ....
-
pw.print("<html><head/><body>A GET request</body></html>");
}
@@ -123,7 +126,8 @@
public void setSessionVariable(HttpServletRequest theRequest)
{
HttpSession session = theRequest.getSession(false);
- session.setAttribute("name_setSessionVariable",
+
+ session.setAttribute("name_setSessionVariable",
"value_setSessionVariable");
}
@@ -134,7 +138,7 @@
*/
public void setRequestAttribute(HttpServletRequest theRequest)
{
- theRequest.setAttribute("name_setRequestAttribute",
+ theRequest.setAttribute("name_setRequestAttribute",
"value_setRequestAttribute");
}
@@ -147,6 +151,7 @@
public Hashtable getRequestParameters(HttpServletRequest theRequest)
{
Hashtable params = new Hashtable();
+
params.put("param1", theRequest.getParameter("param1"));
params.put("param2", theRequest.getParameter("param2"));
@@ -156,6 +161,7 @@
/**
* Get a header from the request.
*
+ * @return a test request header
* @param theRequest the HTTP request
*/
public String getRequestHeader(HttpServletRequest theRequest)
@@ -173,9 +179,13 @@
Hashtable allCookies = new Hashtable();
Cookie[] cookies = theRequest.getCookies();
- if (cookies != null) {
- for (int i = 0; i < cookies.length; i++) {
+
+ if (cookies != null)
+ {
+ for (int i = 0; i < cookies.length; i++)
+ {
Cookie cookie = cookies[i];
+
allCookies.put(cookie.getName(), cookie.getValue());
}
}
@@ -202,8 +212,9 @@
*/
public void setResponseCookie(HttpServletResponse theResponse)
{
- Cookie cookie = new Cookie("responsecookie",
+ Cookie cookie = new Cookie("responsecookie",
"this is a response cookie");
+
cookie.setDomain("jakarta.apache.org");
theResponse.addCookie(cookie);
}
@@ -216,13 +227,18 @@
* @param theRequest the HTTP request
* @param theResponse the HTTP response
* @param theConfig the servlet config object
+ *
+ * @exception IOException on failure
+ * @exception ServletException on failure
*/
- public void doForward(HttpServletRequest theRequest,
- HttpServletResponse theResponse, ServletConfig theConfig)
+ public void doForward(HttpServletRequest theRequest,
+ HttpServletResponse theResponse, ServletConfig theConfig)
throws IOException, ServletException
{
- RequestDispatcher rd = theConfig.getServletContext().
- getRequestDispatcher("/test/test.jsp");
+ RequestDispatcher rd =
+ theConfig.getServletContext().getRequestDispatcher(
+ "/test/test.jsp");
+
rd.forward(theRequest, theResponse);
}
@@ -234,14 +250,18 @@
* @param theRequest the HTTP request
* @param theResponse the HTTP response
* @param theConfig the servlet config object
+ *
+ * @exception IOException on failure
+ * @exception ServletException on failure
*/
- public void doInclude(HttpServletRequest theRequest,
- HttpServletResponse theResponse, ServletConfig theConfig)
+ public void doInclude(HttpServletRequest theRequest,
+ HttpServletResponse theResponse, ServletConfig theConfig)
throws IOException, ServletException
{
- RequestDispatcher rd = theConfig.getServletContext().
- getRequestDispatcher("/test/test.jsp");
+ RequestDispatcher rd =
+ theConfig.getServletContext().getRequestDispatcher(
+ "/test/test.jsp");
+
rd.include(theRequest, theResponse);
}
-
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>