The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

shivkpr (30) [Avatar] Offline
#1
HI Neal,
Ive moved onto the parameterized command examples but when I compile the project, it complains on the
listing.jsp
indicating

Error(3,55): interface java.util.List is abstract; cannot be instantiated

the code is as below

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ page import="java.util.*" %>
<jsp:useBean id="keywords" >
scope="request" class="java.util.List" />
<jsp:useBean id="proposed" >
scope="request" class="java.util.List" />
<html>
<head>
<title>Listing</title>
</head>
<body>

<h1>Listing of Java Keywords</h1>

<c:forEach var="keyword" items="${keywords}">
<code><c:out value="${keyword}"/></code>

</c:forEach>



<h2>Proposed New Keywords</h2>

<c:forEach var="propKeyword" items="${proposed}">
<code><c:out value="${propKeyword}"/></code>

</c:forEach>


<form method="post" action="controller?cmd=formEntry">
<input type="submit" name="Add Keyword" value="Add New Keyword">
</form>


</body>
</html>


Not sure why am getting this

could you please help

thanks
shivkpr (30) [Avatar] Offline
#2
Re: parameterized commands
Hi, i think i may have sorted this .in the listing.jsp
I used
type="java.util.List"
opposed to class

not sure in detail why worked

Main problem is how to run the app
ListingAction does not have a main

Do i need another class to call it or HTM to call it
WOuld apreciate an early response
nford (36) [Avatar] Offline
#3
Re: parameterized commands
Ketan -

The reason that "type" works and "class" doesn't is related to how JSP handles beans it can't find on a collection. If the JSP can't find the bean in one of the standard collections, it tries to instantiate it using the no parameter constructor (which is one of the requirements for a bean). However, in this case, I want to pass any kind of list, so I'm using the abstract java.util.List class. If it is identified as a class, the JSP tries to instantiate it and cannot because it is abstract. Thus, the reason that the "type" attribute exists is for exactly this reason -- you can pass a type (like an abstract class or interface) and the JSP won't try to instantiate a new one.

To execute ListAction, you must run the web application, which loads the MainContoller servlet into memory. The controller is the one that calls the action, depending on the mapping you call from the properties file. So, to call the ListAction, you should deploy the application, then point your browser to
http://localhost:8080/param-command/controller?cmd=listing.

That causes the controller to load and execute the ListAction.
shivkpr (30) [Avatar] Offline
#4
Re: parameterized commands
Thanks,
I did finally got it to work. great help