Bruno Collins

Greenhorn
+ Follow
since Nov 30, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bruno Collins

I know the servlet doesn't produce anything directly, but the servlet forwards to a jsp page that DOES produce the output. The servlet is gathering info from a databases that is then used in the jsp page. Am I missing something.
18 years ago
JSP
Still having problems with this. If someone could at least tell me whether this is possible or not that would be great.
18 years ago
JSP
I have a servlet (MnNav), it extracts a data from a database into a bean. The servlet then forwards to a jsp page (MnNav.jsp) that lists the extracted data.
This works fine stand alone. That is, if you just type http://localhost/servlet/MnNav
However, when I make a new jsp page (Include.jsp)and include the servlet (MnNav) like this,
<html>
<%@ page contentType="text/html" %>
<jsp:include page="/servlet/MnNav" flush="true"/>
</html>
and then type http://localhost/Include.jsp , only the html tags are returned. I placed out.println in both the servlet (MnNav) and MnNav.jsp to see if they execute. Executed standalone both run. Executed from the Include.jsp page only the servlet seems to run.
I know you can include the output of a servlet but if the servlet (which produced not output) then forwards to a jsp page (creating output) will this output get included ??
Thanks.
18 years ago
JSP
When you are new, it is sometimes hard to guage why after a few days you haven't got a response especially when everyone else has. I reposted with a more descriptive subject hoping for better luck. I was unaware of the reply to oneself method.
Agreed the replies I eventually got were great. Thanks everyone.
18 years ago
Every system needs this but I just can't find a good example. I want to be able to maintain a table with the following or similar screen flow. (Let's take a Customer table as the example.) Step:1) Present a list of Customers (Id, Name, Suburb) with a link to View Edit or Delete. At the bottom of the list there would be an Add button. Step:2) When a link is clicked for a Customer, a second screen is displayed based upon the link. i.e. View - show all customer fields (no data entry allowed). Edit - show existing fields & values and allow editing. Delete - show all fields (protected) with an Are you sure Y/N dialogue. Add - initialise field with default values and allow entry. There would be a button to Cancel and one to Process. The Cancel button would go back to the List (1) and the Process button would validate the fields and redisplay (2) with appropriate messages should there be errors. Step:3) When there were no errors and the mode is Add/Edit/Delete the table would be updated accordingly and a final screen displayed confirming all was OK. For a View just go back to the list.
My approach (MVC) is: 1 servlet CustomerMaint which does all the flow control & database access. It would use 2 beans one to hold the list of Customers and a second to hold the details of the chosen customer. The servlet would forward to three jsp pages a) CustomerList b) CustomerMaint c) UpdateOk.
I am open to suggestions & recommendations.
18 years ago
Thanks I will give it a try.
18 years ago
JSP
Every system needs this but I just can't find a good example. I want to be able to maintain a table with the following or similar screen flow. (Let's take a Customer table as the example.) Step:1) Present a list of Customers (Id, Name, Suburb) with a link to View Edit or Delete. At the bottom of the list there would be an Add button. Step:2) When a link is clicked for a Customer, a second screen is displayed based upon the link. i.e. View - show all customer fields (no data entry allowed). Edit - show existing fields & values and allow editing. Delete - show all fields (protected) with an Are you sure Y/N dialogue. Add - initialise field with default values and allow entry. There would be a button to Cancel and one to Process. The Cancel button would go back to the List (1) and the Process button would validate the fields and redisplay (2) with appropriate messages should there be errors. Step:3) When there were no errors and the mode is Add/Edit/Delete the table would be updated accordingly and a final screen displayed confirming all was OK. For a View just go back to the list.
My approach (MVC) is: 1 servlet CustomerMaint which does all the flow control & database access. It would use 2 beans one to hold the list of Customers and a second to hold the details of the chosen customer. The servlet would forward to three jsp pages a) CustomerList b) CustomerMaint c) UpdateOk.
I am open to suggestions & recommendations.
18 years ago
Error page looks like this:
<%@ page contentType="text/html" %>
<%@ page isErrorPage="true" %>
<html>
<link rel="stylesheet" type="text/css" href="../monstyle.css">
<h1>Sorry! an error has occured.</h1>
<blockquote>
Error message:<%= exception.getMessage() %><br>
Java exception:<%= exception.toString() %><br>
JSP requested:<%=request.getServerName()+request.getRequestURI() %><br>
</blockquote>
<% System.out.println("jsp_error_page: Error in JSP: " + request.getServerName()
+ request.getRequestURI() + ". Exception was: "+exception.toString()); %>
<h2>Please contact support.</h2>
</html>
Page creating the error:
<%@ page contentType="text/html" %>
<%@ page errorPage="/MonError.jsp" %>
<%@ page import="java.util.*" %>
<html>
<link rel="stylesheet" type="text/css" href="../monstyle.css">
<body>
<h2>Group List</h2>
<table cellpadding="0" cellspacing="0">
<tr>
<th>Group Code</th>
<th>Group Description</th>
<th>Edit</th>
<th>Delete</th>
<th>Copy</th>
</tr>
<jsp:useBean id="mglb" scope="request" class="com.primur.monitor.MonGroupListBean"/>
<%
String rowStyle = "tr1";
Vector grouplist = (Vector)request.getAttribute("grouplist") ;
for (Enumeration e = grouplist.elements() ; e.hasMoreElements() {
mglb =(com.primur.monitor.MonGroupListBean)e.nextElement();
%>
<tr class="<%=rowStyle %>">
<td> <a title="View" href="MonGroupMaint?mode=view&id=<%= mglb.getGrgrpc() %>">
<%= mglb.getGrgrpc() %></td>
<td><%= mglb.getGrdesc() %></td>
<td>
<p align="center">
<a href="MonGroupMaint?mode=edit&id=<%= mglb.getGrgrpc() %>">
<img border="0" src="../edt.gif" width="22" height="20" alt="Edit"></a></td>
<td>
<p align="center">
<a href="MonGroupMaint?mode=delete&id=<%= mglb.getGrgrpc() %>">
<img border="0" src="../del.gif" width="22" height="20" alt="Delete"></a></td>
<td>
<p align="center">
<a href="MonGroupMaint?mode=copy&id=<%= mglb.getGrgrpc() %>">
<img border="0" src="../cpy.gif" width="22" height="20" alt="Copy"></a></td>
</tr>
<%
if (rowStyle=="tr1"){
rowStyle = "tr2";
}
else {
rowStyle = "tr1";
}
}
<%
if (true)
throw new Exception("This is my test"); // test error page
%>
%>
</table>
<p></p>
<a href="MonGroupMaint?mode=add">Add New User</a>
</body>
<html>
The error page appears in a cell of the page's table.
18 years ago
JSP
I have a JSP page that has an error page defined. This works, however depending upon where the error occurs in the jsp page all of the page up to the point of the error is also displayed. If I induce an error at the top of the page just the error page is visible. If I induce an error somewhere later in the page say in a table cell the contents of the error page appears here with the rest of the page. It is as if the error page is an include.
18 years ago
JSP
I have a fresh install of DB2 7.2, WAS 4.0 on a Windows 2000 server and have ALMOST got the Petstore demo working. I have followed the instructions and it mostly works however I get the followinf error when addind to the basket, creating a new account. Any ideas anyone .....please!
Server Error
CORBA OBJECT_NOT_EXIST 0 No; nested exception is: org.omg.CORBA.OBJECT_NOT_EXIST: minor code: 0 completed: No
Oops! Your request cannot be completed. The server got the following error.

com.sun.j2ee.blueprints.petstore.control.exceptions.GeneralFailureException: CORBA OBJECT_NOT_EXIST 0 No; nested exception is:
org.omg.CORBA.OBJECT_NOT_EXIST: minor code: 0 completed: No
at com.sun.j2ee.blueprints.petstore.control.web.ShoppingClientControllerWebImpl.handleEvent(ShoppingClientControllerWebImpl.java:142)
at com.sun.j2ee.blueprints.petstore.control.web.RequestProcessor.processRequest(RequestProcessor.java:85)
at com.sun.j2ee.blueprints.petstore.control.web.MainServlet.doProcess(MainServlet.java:111)
at com.sun.j2ee.blueprints.petstore.control.web.MainServlet.doGet(MainServlet.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:718)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:287)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:428)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:870)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:788)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:439)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:239)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:104)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:61)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:132)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:125)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:271)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:49)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:303)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:232)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122)

Please notify the administrator. Thank you.
18 years ago
On the commercial JSP/Servlet containers such as WebSphere etc they have facilities to setup database connection pools (datasources). What do people do when they want to use connection pools on a Tomcat server. Do you write your own connection pool code (servlet?) or are there ones that others have written. Are there any popular/recommended ones. I don't think I need an all singing all dancing one. One that can just do the basic connection pool functions.
What's the way to go here?
18 years ago
I understand that it is best practice to use database connection pooling to improve performance. On the commercial containers such as WebSphere they have facilities to set connection pools. What do people do when they want to use connection pools on a Tomcat server. Do you write your own connection pool code (servlet?) or use one that others have written. Are there any popular/recommended ones.
What's the way to go here?
If I code, lets say, retrieval from a database a list of records that match some criteria. I can do this basically one of two ways, a) Servlet that runs a query, populates a bean and then displays in a JSP -OR- b) do the lot in the JSP.
Which is faster? Does one consume significantly more resources than the other?
Let's ignore for the purpose of this post usual MVC benefits (maintenance & separation of duties etc).
18 years ago
I am using a bean to store the result of a SQL query. When creating a bean to hold this info should I initialise the various fields in the declaration or is this overkill given?
eg:
public class MyBean {
private String mydata = "";
-OR-
public class MyBean {
private String mydata;
Thanks
18 years ago
Thanks for the link. I'll check it out.
18 years ago