Author: vgritsenko
Date: Tue Oct 2 09:55:49 2007
New Revision: 581305
URL: http://svn.apache.org/viewvc?rev=581305&view=rev
Log:
fix deprecation
Modified:
xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/AddContact.java
xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DBConnection.java
xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DeleteContact.java
xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/EditContact.java
xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/ListContacts.java
xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/SearchContacts.java
xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/Task.java
Modified: xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/AddContact.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/AddContact.java?rev=581305&r1=581304&r2=581305&view=diff
==============================================================================
--- xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/AddContact.java (original)
+++ xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/AddContact.java Tue Oct 2 09:55:49 2007
@@ -35,11 +35,9 @@
// Add document to the datbase using values passed in via form-post
public boolean add(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
- Collection col = null;
- String ourdoc = null;
-
+ Collection col;
+ String ourdoc;
try {
-
// Get a copy of the collection instance
col = getCollection(request,response);
@@ -66,16 +64,16 @@
} catch ( Exception e) {
e.printStackTrace();
- // there's not much else we can do if the response is committed
- if (response.isCommitted())
- return true;
+ // there's not much else we can do if the response is committed
+ if (response.isCommitted()) {
+ return true;
+ }
// Catch the exception and send the user to the error page
if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
- }
- else {
- response.sendRedirect("/addressbook/error.jsp" );
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
+ } else {
+ response.sendRedirect("/addressbook/error.jsp");
}
}
Modified: xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DBConnection.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DBConnection.java?rev=581305&r1=581304&r2=581305&view=diff
==============================================================================
--- xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DBConnection.java (original)
+++ xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DBConnection.java Tue Oct 2 09:55:49 2007
@@ -65,9 +65,9 @@
// Catch the exception and send the user to the error page
if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
} else {
- response.sendRedirect("/addressbook/error.jsp" );
+ response.sendRedirect("/addressbook/error.jsp");
}
}
Modified: xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DeleteContact.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DeleteContact.java?rev=581305&r1=581304&r2=581305&view=diff
==============================================================================
--- xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DeleteContact.java (original)
+++ xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/DeleteContact.java Tue Oct 2 09:55:49 2007
@@ -35,10 +35,8 @@
// Delete the document with a key value of request.index
public boolean delete(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
- Collection col = null;
-
+ Collection col;
try {
-
// Get a reference to the session
HttpSession session = request.getSession(true);
@@ -46,11 +44,11 @@
col = getCollection(request,response);
// Get the index we are going to delete
- int index = Integer.parseInt((String)request.getParameter("index"));
+ int index = Integer.parseInt(request.getParameter("index"));
// Pull the Group out of the session, and get the Person instance at the Index
Group group = (Group)session.getAttribute("group");
- Person person = (Person)group.getPersonAt(index);
+ Person person = group.getPersonAt(index);
// Get the documentKey for this particular Person
String dockey = person.getDocKey();
@@ -59,18 +57,18 @@
col.removeResource(col.getResource(dockey) );
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
- // there's not much else we can do if the response is committed
- if (response.isCommitted())
- return true;
+ // there's not much else we can do if the response is committed
+ if (response.isCommitted()) {
+ return true;
+ }
// Catch the exception and send the user to the error page
if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
- }
- else {
- response.sendRedirect("/addressbook/error.jsp" );
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
+ } else {
+ response.sendRedirect("/addressbook/error.jsp");
}
}
Modified: xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/EditContact.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/EditContact.java?rev=581305&r1=581304&r2=581305&view=diff
==============================================================================
--- xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/EditContact.java (original)
+++ xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/EditContact.java Tue Oct 2 09:55:49 2007
@@ -40,11 +40,9 @@
public boolean edit(HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
- Collection col = null;
- String ourdoc = null;
-
+ Collection col;
+ String ourdoc;
try {
-
// Get the collection instance
col = getCollection(request,response);
@@ -73,16 +71,16 @@
} catch ( Exception e) {
e.printStackTrace();
- // there's not much else we can do if the response is committed
- if (response.isCommitted())
- return true;
+ // there's not much else we can do if the response is committed
+ if (response.isCommitted()) {
+ return true;
+ }
// Catch the exception and send the user to the error page
if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
- }
- else {
- response.sendRedirect("/addressbook/error.jsp" );
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
+ } else {
+ response.sendRedirect("/addressbook/error.jsp");
}
}
Modified: xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/ListContacts.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/ListContacts.java?rev=581305&r1=581304&r2=581305&view=diff
==============================================================================
--- xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/ListContacts.java (original)
+++ xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/ListContacts.java Tue Oct 2 09:55:49 2007
@@ -39,8 +39,7 @@
public boolean list(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
- Collection col = null;
-
+ Collection col;
try {
// Get a reference to the session
HttpSession session = request.getSession(true);
@@ -64,19 +63,18 @@
group.addResults(results);
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
- // there's not much else we can do if the response is committed
- if (response.isCommitted())
- return true;
- e.printStackTrace();
+ // there's not much else we can do if the response is committed
+ if (response.isCommitted()) {
+ return true;
+ }
// Catch the exception and send the user to the error page
if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
- }
- else {
- response.sendRedirect("/addressbook/error.jsp" );
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
+ } else {
+ response.sendRedirect("/addressbook/error.jsp");
}
}
Modified: xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/SearchContacts.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/SearchContacts.java?rev=581305&r1=581304&r2=581305&view=diff
==============================================================================
--- xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/SearchContacts.java (original)
+++ xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/SearchContacts.java Tue Oct 2 09:55:49 2007
@@ -37,66 +37,64 @@
public boolean attributeSearch(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
- Collection col = null;
+ Collection col;
String xpath = null;
-
try {
-
- HttpSession session = request.getSession(true);
+ HttpSession session = request.getSession(true);
- // Get a collection instance
- col = getCollection(request,response);
+ // Get a collection instance
+ col = getCollection(request,response);
- XPathQueryService service = (XPathQueryService)col.getService("XPathQueryService",XMLDBAPIVERSION);
+ XPathQueryService service = (XPathQueryService)col.getService("XPathQueryService",XMLDBAPIVERSION);
- // Get the seach parameters from the form
- String searchtype = request.getParameter("SEARCHTYPE");
- String searchstring = request.getParameter("SEARCHSTRING");
-
- // Setup xpath string depending on search type
- if ( searchtype.equals("fname") || searchtype.equals("lname") ) {
- xpath = "/person[" + searchtype + "='" + searchstring + "']";
- } else if ( searchtype.equals("workphone")) {
- xpath = "/person[phone/@type='work' and phone/text() = '" + searchstring + "' ]" ;
- } else if ( searchtype.equals("homephone")) {
- xpath = "/person[phone/@type='home' and phone/text() = '" + searchstring + "' ]" ;
- } else if ( searchtype.equals("cellphone")) {
- xpath = "/person[phone/@type='cell' and phone/text() = '" + searchstring + "' ]" ;
- } else if ( searchtype.equals("homeemail")) {
- xpath = "/person[email/@type='home' and email/text() = '" + searchstring + "' ]" ;
- } else if ( searchtype.equals("workemail")) {
- xpath = "/person[email/@type='work' and email/text() = '" + searchstring + "' ]" ;
- } else if ( searchtype.equals("homeaddress")) {
- xpath = "/person[address/@type='home' and address/text() = '" + searchstring + "' ]" ;
- } else if ( searchtype.equals("workaddress")) {
- xpath = "/person[address/@type='work' and address/text() = '" + searchstring + "' ]" ;
- }
-
- ResourceSet resultSet = service.query(xpath);
- ResourceIterator results = resultSet.getIterator();
+ // Get the seach parameters from the form
+ String searchtype = request.getParameter("SEARCHTYPE");
+ String searchstring = request.getParameter("SEARCHSTRING");
+
+ // Setup xpath string depending on search type
+ if ( searchtype.equals("fname") || searchtype.equals("lname") ) {
+ xpath = "/person[" + searchtype + "='" + searchstring + "']";
+ } else if ( searchtype.equals("workphone")) {
+ xpath = "/person[phone/@type='work' and phone/text() = '" + searchstring + "' ]" ;
+ } else if ( searchtype.equals("homephone")) {
+ xpath = "/person[phone/@type='home' and phone/text() = '" + searchstring + "' ]" ;
+ } else if ( searchtype.equals("cellphone")) {
+ xpath = "/person[phone/@type='cell' and phone/text() = '" + searchstring + "' ]" ;
+ } else if ( searchtype.equals("homeemail")) {
+ xpath = "/person[email/@type='home' and email/text() = '" + searchstring + "' ]" ;
+ } else if ( searchtype.equals("workemail")) {
+ xpath = "/person[email/@type='work' and email/text() = '" + searchstring + "' ]" ;
+ } else if ( searchtype.equals("homeaddress")) {
+ xpath = "/person[address/@type='home' and address/text() = '" + searchstring + "' ]" ;
+ } else if ( searchtype.equals("workaddress")) {
+ xpath = "/person[address/@type='work' and address/text() = '" + searchstring + "' ]" ;
+ }
+
+ ResourceSet resultSet = service.query(xpath);
+ ResourceIterator results = resultSet.getIterator();
- Group group = (Group)session.getAttribute("group");
+ Group group = (Group)session.getAttribute("group");
- // Clear out group object...
- group.removeAll();
+ // Clear out group object...
+ group.removeAll();
- // Add results to Group instance
- group.addResults(results);
+ // Add results to Group instance
+ group.addResults(results);
} catch(Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
- // there's not much else we can do if the response is committed
- if (response.isCommitted())
- return true;
-
- // Catch the exception and send the user to the error page
- if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
- }
- else {
- response.sendRedirect("/addressbook/error.jsp" );
- }
+ // there's not much else we can do if the response is committed
+ if (response.isCommitted()) {
+ return true;
+ }
+
+ // Catch the exception and send the user to the error page
+ if (e.getMessage() != null ) {
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
+ } else {
+ response.sendRedirect("/addressbook/error.jsp");
+ }
}
return true;
@@ -104,47 +102,45 @@
public boolean xpathSearch(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
- Collection col = null;
-
- try {
-
- HttpSession session = request.getSession(true);
-
- // Get a collection instance
- col = getCollection(request,response);
+ Collection col;
+ try {
+ HttpSession session = request.getSession(true);
- XPathQueryService service = (XPathQueryService)col.getService("XPathQueryService",XMLDBAPIVERSION);
-
- // Get the seach parameters from the form
- String searchstring = request.getParameter("SEARCHSTRING");
+ // Get a collection instance
+ col = getCollection(request,response);
+
+ XPathQueryService service = (XPathQueryService) col.getService("XPathQueryService", XMLDBAPIVERSION);
+
+ // Get the seach parameters from the form
+ String searchstring = request.getParameter("SEARCHSTRING");
- ResourceSet resultSet = service.query(searchstring);
- ResourceIterator results = resultSet.getIterator();
+ ResourceSet resultSet = service.query(searchstring);
+ ResourceIterator results = resultSet.getIterator();
- Group group = (Group)session.getAttribute("group");
+ Group group = (Group)session.getAttribute("group");
- // Clear out group object...
- group.removeAll();
+ // Clear out group object...
+ group.removeAll();
- // Add results to Group instance
- group.addResults(results);
+ // Add results to Group instance
+ group.addResults(results);
- } catch(Exception e) {
- e.printStackTrace();
+ } catch(Exception e) {
+ e.printStackTrace();
- // there's not much else we can do if the response is committed
- if (response.isCommitted())
- return true;
-
- // Catch the exception and send the user to the error page
- if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
- }
- else {
- response.sendRedirect("/addressbook/error.jsp" );
- }
- }
+ // there's not much else we can do if the response is committed
+ if (response.isCommitted()) {
+ return true;
+ }
+
+ // Catch the exception and send the user to the error page
+ if (e.getMessage() != null ) {
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
+ } else {
+ response.sendRedirect("/addressbook/error.jsp");
+ }
+ }
- return true;
+ return true;
}
}
Modified: xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/Task.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/Task.java?rev=581305&r1=581304&r2=581305&view=diff
==============================================================================
--- xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/Task.java (original)
+++ xml/xindice/trunk/java/examples/addressbook/src/java/addressbook/Task.java Tue Oct 2 09:55:49 2007
@@ -18,7 +18,7 @@
*
* $Id$
*/
-
+
import java.beans.Beans;
import java.io.IOException;
import java.net.URLEncoder;
@@ -28,7 +28,6 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspFactory;
import javax.servlet.jsp.PageContext;
@@ -43,130 +42,124 @@
public void doPost(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
- JspFactory jspFactory = null;
- PageContext pageContext = null;
- HttpSession session = null;
- Group group = null;
-
- String action = null;
-
- try {
-
- // If the Group bean hasn't been added to the session alerady, add it
- // this allows the user to go directly to ANY page
- jspFactory = JspFactory.getDefaultFactory();
- pageContext = jspFactory.getPageContext(this, request, response, "/error.jsp", true, 8192, true );
- session = pageContext.getSession();
-
- group = (Group)pageContext.getAttribute("group",PageContext.SESSION_SCOPE);
- if (group == null) {
- group=(Group)Beans.instantiate(this.getClass().getClassLoader(), "addressbook.Group" );
- pageContext.setAttribute("group", group, PageContext.SESSION_SCOPE );
- }
-
-
- // Since case matters, we need to check for both....
- if ( request.getParameter("action") != null ) {
- action = request.getParameter("action");
- }
- else {
- action = request.getParameter("ACTION");
- }
-
- // Decide where to send the user depending on value of action
- if ( action != null ) {
- // Add a Contact
- if ( action.equalsIgnoreCase("addform") ) {
- gotoPage("/addContact.jsp",request,response);
- } else if ( action.equalsIgnoreCase("addcontact") ) {
- AddContact contact = new AddContact();
- contact.add(request,response);
-
- ListContacts lcontact = new ListContacts();
- lcontact.list(request,response);
- gotoPage("/listContacts.jsp",request,response);
-
- // List all contacts
- } else if ( action.equalsIgnoreCase("listcontacts") ) {
- ListContacts contact = new ListContacts();
- contact.list(request,response);
- gotoPage("/listContacts.jsp",request,response);
-
- // Show individual Contact detail
- } else if ( action.equalsIgnoreCase("showcontact") ) {
- gotoPage("/showContact.jsp",request,response);
-
- // Show individual XML file
- } else if ( action.equalsIgnoreCase("showxml") ) {
- gotoPage("/showXML.jsp",request,response);
-
- // Edit a contact
- } else if ( action.equalsIgnoreCase("editcontactform") ) {
- gotoPage("/editContactForm.jsp",request,response);
- } else if ( action.equalsIgnoreCase("editcontact") ) {
- EditContact contact = new EditContact();
- contact.edit(request,response);
-
- ListContacts lcontact = new ListContacts();
- lcontact.list(request,response);
- gotoPage("/listContacts.jsp",request,response);
-
- // Search for a contact
- } else if ( action.equalsIgnoreCase("searchform") ) {
- gotoPage("/searchContacts.jsp",request,response);
- } else if ( action.equalsIgnoreCase("attributesearch") ) {
- SearchContacts contact = new SearchContacts();
- contact.attributeSearch(request,response);
- gotoPage("/listContacts.jsp",request,response);
- } else if ( action.equalsIgnoreCase("xpathsearch") ) {
- SearchContacts contact = new SearchContacts();
- contact.xpathSearch(request,response);
- gotoPage("/listContacts.jsp",request,response);
-
- // Delete a contact
- } else if ( action.equalsIgnoreCase("deletecontact") ) {
- DeleteContact contact = new DeleteContact();
- contact.delete(request,response);
-
- ListContacts lcontact = new ListContacts();
- lcontact.list(request,response);
- gotoPage("/listContacts.jsp",request,response);
-
- } else gotoPage("/error.jsp",request,response);
- }
- else {
- gotoPage("/error.jsp",request,response);
- }
-
- } catch( Exception e ) {
- e.printStackTrace();
-
- // there's not much else we can do if the response is committed
- if (response.isCommitted())
- return;
-
- // Catch the exception and send the user to the error page
- if (e.getMessage() != null ) {
- response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage()) );
- }
- else {
- response.sendRedirect("/addressbook/error.jsp" );
- }
- }
- }
-
- // Treat a form-get as a post, seding user to doPost
- public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
-
- doPost(request,response);
-
+ JspFactory jspFactory;
+ PageContext pageContext;
+ Group group;
+ String action;
+ try {
+ // If the Group bean hasn't been added to the session alerady, add it
+ // this allows the user to go directly to ANY page
+ jspFactory = JspFactory.getDefaultFactory();
+ pageContext = jspFactory.getPageContext(this, request, response, "/error.jsp", true, 8192, true );
+
+ group = (Group)pageContext.getAttribute("group",PageContext.SESSION_SCOPE);
+ if (group == null) {
+ group=(Group)Beans.instantiate(this.getClass().getClassLoader(), "addressbook.Group" );
+ pageContext.setAttribute("group", group, PageContext.SESSION_SCOPE );
+ }
+
+
+ // Since case matters, we need to check for both....
+ if ( request.getParameter("action") != null ) {
+ action = request.getParameter("action");
+ }
+ else {
+ action = request.getParameter("ACTION");
+ }
+
+ // Decide where to send the user depending on value of action
+ if ( action != null ) {
+ // Add a Contact
+ if ( action.equalsIgnoreCase("addform") ) {
+ gotoPage("/addContact.jsp",request,response);
+ } else if ( action.equalsIgnoreCase("addcontact") ) {
+ AddContact contact = new AddContact();
+ contact.add(request,response);
+
+ ListContacts lcontact = new ListContacts();
+ lcontact.list(request,response);
+ gotoPage("/listContacts.jsp",request,response);
+
+ // List all contacts
+ } else if ( action.equalsIgnoreCase("listcontacts") ) {
+ ListContacts contact = new ListContacts();
+ contact.list(request,response);
+ gotoPage("/listContacts.jsp",request,response);
+
+ // Show individual Contact detail
+ } else if ( action.equalsIgnoreCase("showcontact") ) {
+ gotoPage("/showContact.jsp",request,response);
+
+ // Show individual XML file
+ } else if ( action.equalsIgnoreCase("showxml") ) {
+ gotoPage("/showXML.jsp",request,response);
+
+ // Edit a contact
+ } else if ( action.equalsIgnoreCase("editcontactform") ) {
+ gotoPage("/editContactForm.jsp",request,response);
+ } else if ( action.equalsIgnoreCase("editcontact") ) {
+ EditContact contact = new EditContact();
+ contact.edit(request,response);
+
+ ListContacts lcontact = new ListContacts();
+ lcontact.list(request,response);
+ gotoPage("/listContacts.jsp",request,response);
+
+ // Search for a contact
+ } else if ( action.equalsIgnoreCase("searchform") ) {
+ gotoPage("/searchContacts.jsp",request,response);
+ } else if ( action.equalsIgnoreCase("attributesearch") ) {
+ SearchContacts contact = new SearchContacts();
+ contact.attributeSearch(request,response);
+ gotoPage("/listContacts.jsp",request,response);
+ } else if ( action.equalsIgnoreCase("xpathsearch") ) {
+ SearchContacts contact = new SearchContacts();
+ contact.xpathSearch(request,response);
+ gotoPage("/listContacts.jsp",request,response);
+
+ // Delete a contact
+ } else if ( action.equalsIgnoreCase("deletecontact") ) {
+ DeleteContact contact = new DeleteContact();
+ contact.delete(request,response);
+
+ ListContacts lcontact = new ListContacts();
+ lcontact.list(request,response);
+ gotoPage("/listContacts.jsp",request,response);
+
+ } else gotoPage("/error.jsp",request,response);
+ }
+ else {
+ gotoPage("/error.jsp",request,response);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ // there's not much else we can do if the response is committed
+ if (response.isCommitted())
+ return;
+
+ // Catch the exception and send the user to the error page
+ if (e.getMessage() != null) {
+ response.sendRedirect("/addressbook/error.jsp?error=" + URLEncoder.encode(e.getMessage(), "UTF-8"));
+ } else {
+ response.sendRedirect("/addressbook/error.jsp");
+ }
+ }
}
- // Forward the user on to the pages specified in address
- private void gotoPage( String address, HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
-
- RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(address);
- dispatcher.forward(request, response);
-
- }
+ // Treat a form-get as a post, seding user to doPost
+ public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
+
+ doPost(request,response);
+
+ }
+
+ // Forward the user on to the pages specified in address
+ private void gotoPage( String address, HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
+
+ RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(address);
+ dispatcher.forward(request, response);
+
+ }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.