Mapping in jsp
hi buddies...
i have a requirement..
need to import a file... display its fields on jsp against field values fetched from db.. user will map the fields of file and db... n then records will be transferred from file to db...
can anyone help as to how this requirement can be approached... pls also send if u have any links..
thankx : )
The following tag will import a file:
<input type="file"
If you look this up, you can find some examples of how to use it.
see also:
http://forum.java.sun.com/thread.jspa?threadID=5194054&messageID=9763980#9763980
Similar Messages
-
How does *.jsf extension map to *.jsp extension and where it is mapped
Hi ,
How does *.jsf extension map to *.jsp extension and where it is mapped ?
ThanksHow does *.jsf extension map to *.jsp extension and where it is mapped ?It is mapped in the web.xml.
If you add the following in your web.xml:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
The *.jsf will be mapped to the file with the same name, but xhtml as extention.
if you the javax.faces.DEFAULT_SUFFIX is not defined in the web.xml, the default suffix comes from the one of the constant of javax.faces.application.ViewHandler . This constant names DEFAULT_SUFFIX and equals to ".jsp"
Look at:
http://java.sun.com/j2ee/javaserverfaces/1.1/docs/api/constant-values.html
Sergey : http://jsfTutorials.net -
How to map ALL .jsp to a Main servlet ?
the problem is that i want to submit all forms on web pages to be processed by servler but to see in adress bar of my browser url with .jsp
i tried to map main sertvlet in such a way
<url-mapping>/*.jsp</url-mapping>
but it didn't work...
is there a way to invoke servlet but to see *. jsp as an url ?
in other word, is it possible by calling index.jsp invoke some servlet behind the scene ?
if i could map *.jsp this could be done automatically.....In theory you can use:<url-mapping>/*.jsp</url-mapping>However most web servers already intercept that mapping and it may bypass your mapping.
For example in Tomcat there is a web descriptor in the <TOMCAT_HOME>/conf directory that maps all jsp extensions to org.apache.jasper.servlet.JspServlet.
If you want to work with jsps on this level, try using filters intead, they may not be affected by the JspServlet as they have to pass through the filter first.
Anthony -
How to get the action-mapping in jsp page in struts
Hi,
I want get, in my login.jsp, the name of action mapping that call my
login.jsp.
Is possible?
suppose abc.do called my login.jsp
now i need to know the name of action-mapping here abc
Thanks,Depending on what you need, I believe Struts 1.3 creates a request attribute called "org.apache.struts.globals.ORIGINAL_URI_KEY". In your case, it looks like this would be set to the string "/abc.do". There should also be a request attribute called "org.apache.struts.action.mapping.instance" that contains an instance of ActionConfig. I think both of those keys are defined by the Globals class.
-
Getting "unique constraint" error while mapping customized jsp
Hi,
We are implementing iStore R12 (12.1.3).
We have customized ibeCCtdMenu.jsp, renamed it as xxibeCCtdMenu.jsp and moved it to $OA_HTML/ folder.
Now in template manager, we are creating a new source file (xxibeCCtdMenu.jsp) under "Menu generation template".
However when we select site and language as "All", it gives following error:
Error in saving logical to physical mapping
ORA-00001: unique constraint (IBE.IBE_DSP_LGL_PHYS_MAP_U2) violated in Package IBE_PhysicalMap_GRP Procedure save_physicalmap
All sites and all language exists already exists for deliverable 7670
How can we overcome this error? Please advise.
Thanks,
Vivekfor a given combination of Site and Language, only one template can exists.
Default file provided by Oracle is set with combination as All Sites - All Languages, and you will not be able to change it.
Register your file with combination such as All Sites - English Language
or <specific site>, All language.
Then it will work fine.
Hrishikesh -
Problem using image-map in JSP
hello experts,
i have a stupid issue which i am not able to sort out. i have a JSP page with a function which returns a bufferedImage. i am using
<img src="<%=ImageIO.write(displayChart(),"png",response.getOutputStream())%>" usemap="#barmap">to display the image and is working fine and image is getting displayed. but the map is not getting activated .
please help me outDouble posted.
-
URL mapping between jsp and servlet
recently, I try glassfish, and I get surprised, for example My application name is HelloWorld if I have jsp action to servlet I can't use action ="servlet/myservlet1" I have to use
action="HelloWorld/myservlet " if I put my servlet2 under test folder I can't call this servlet by servlet/test.servlet2, I have to use HelloWorld/servlet2,. I realize that is not glassfish problem , I just wonder is any one could give more expiration on servlet mapping ??
Thank you !Depends on several factors. In which context and how exactly are you specifying the URL? In client context, the leading "/" brings you to domain root. In servlet context, the leading "/" brings you to context root. The HTML <a> element is relative to client context and JSTL <c:url> is relative to servlet context. That kind of things.
-
Can any body tell me how to map the jsp page with sling servlet
here is my content.jsp
<%@include file="/libs/foundation/global.jsp"%>
<cq:include script="/libs/wcm/core/components/init/init.jsp"/>
<div>
<h3>Login</h3>
<form name="frm" method="doGet" action="/LoginServlet">
<cq:include path="texot" resourceType="sapphirenow_web/components/foundation/textlog"/>
<cq:include path="text1" resourceType="sapphirenow_web/components/foundation/textlog"/>
<cq:include path="text3" resourceType="sapphirenow_web/components/foundation/submit"/>
</form>
</div>
here is my LoginServlet.java
package com.sapphirenow.web;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
* @scr.component metatype="true"
* @scr.service interface="javax.servlet.Servlet"
* @scr.property name="sling.servlet.paths" value="/bin/mn"
* @scr.property name="sling.servlet.methods" values="GET"
public class LoginServlet extends SlingAllMethodsServlet
public void doGet(SlingHttpServletRequest request,SlingHttpServletResponse response) throws ServletException,IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name = request.getParameter("Username");
String pass = request.getParameter("Password");
out.println("<html>");
out.println("<body>");
out.println("Thanks Mr." + " " + name + " " + "for visiting roseindia<br>" );
out.println("Now you can see your password : " + " " + pass + "<br>");
out.println("</body></html>");
its showing "The requested URL /LoginServlet was not found on this server." how to solve this pls help meHi,
Bellow some links which maybe hepls you:
-> http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html
-> http://edivad.wordpress.com/2011/07/18/cq-sling-servlets-resourcetype/
-> http://sling.apache.org/site/servlets.html
-> http://blogs.adobe.com/aaa/tag/sling
and some threads from the forum:
-> http://forums.adobe.com/message/4943006#4943006
-> http://forums.adobe.com/message/4915799#4915799
By the way there is a lot of information which you can find in th network.
Regards,
kasq -
JSP mapping with Tomcat 5.0.27
With Jakarta-Tomcat 5.0.27 is it possible to put a JSP file in a sub-directory of a web application and be able to "servlet-mapping" it to only create one object? If so how do you write the web.xml entry? I only want to create one InitTest object, not two of them!
If I place InitTest.jsp in the following directory structure:
C:\tomcat\webapps\web-app\subDirectory\InitTest.jsp
This web.xml entry does not work:
<servlet>
<servlet-name>InitTest</servlet-name>
<jsp-file>/subDir/InitTest.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>InitTest</servlet-name>
<url-pattern>/InitTest.jsp</url-pattern>
</servlet-mapping>When I use this link:
http://localhost:8080/web-app/subDir/InitTest.jsp
I get "jsp" as the servlet name
and
When I use this link:
http://localhost:8080/web-app/servlet/InitTest
I get "InitTest" as the servlet name
How do I map InitTest.jsp correctly when it's placed in a sub-directory of the web application's directory?dear friend...y do you want to map your jsp page?? you can directly access your jsp from your location. You dont needd to map in the web.xml. You need to map only servlets not jsps
regards
shanu -
Quick question about url/jsp mapping
Could anyone clarify whether the following mapping in the web.xml file is possible?
I want to access the file webapps\examples\gate\login.jsp by going to the page http://192.168.2.143:8080/work/login.jsp instead of http://192.168.2.143:8080/examples/gate/login.jsp
Currently I can map it fine to http://192.168.2.143:8080/examples/work/login.jsp,
which is an existing folder, but when I try and get it above the examples folder, it gives me the 404 error.
<servlet>
<servlet-name>Login</servlet-name>
<jsp-file>/gate/login.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/../work/login.jsp</url-pattern>
</servlet-mapping>Using only work/login.jsp will cause an error, and the tomcat server to crash, if I use the pattern
<url-pattern>/work/login.jsp</url-pattern>, I just map the URL http://192.168.2.143:8080/examples/work/login.jsp instead of
http://192.168.2.143:8080/examples/gate/login.jsp
My entire webaps structure is rather long, and contains code other than my own, so I'd rather not post it, I just need to figure out if it is possible to map the jsp page to a path above the file. (do you think I need to do it in another web.xml?) -
I've a directory structure in Tomcat that looks like :
TOMCAT_HOME\webapps\Security\jsp\
Guys I need help on JSP mapping.
I'm running Tomcat and I want all the /Security/*.jsp requests in Browser goto above context.
i.e. http://localhost/Security/AJSP1.jsp
should go an invoke TOMCAT_HOME\webapps\Security\jsp\AJSP1.jsp
I donot want to manually map each JSP file in web.xml .
I just want any browser request with URL
http://localhost/Security/*.jsp
goto TOMCAT_HOME\webapps\Security\jsp\
Is there a way around.
Thanks in advance.
samPut it in the conf/server.xml file. Check Tomcaat documentation for proper location. Here is a small ex.
<Context path="/Security" docBase="<physical location>" debug="0" reloadable="true" crossContext="true" /> -
JSP mapping for REST based URLs
Hi,
I am in the middle of developing a web app for which I would like to have REST styles URLs like
http://localhost/myfotoapp/
http://localhost/myfotoapp/<album-name-here> or http//localhost/myfotoapp/album/<album-name-here>
http//localhost/myfotoapp/<album-name-here>/<my-foto-1> or http://localhost/myfotoapp/album/<album-name-here>/foto/<my-foto-2>I am hoping to just write 3 jsp pages for the URLs above (in the same order)
AllAlbums.jsp ( display the thumbnails of albums)
Album.jsp ( display the thumbnails of pictures in a particular album - get album name from URL)
Foto.jsp ( display a particular image - get the name of the image from the URL)
How would I map the jsps to the respective URLs ? I was hoping to map the 3 jsp above with /*, /album/*, /album/*/foto/* but that does I just realized that the wildcard character '*' in the servlet-mapping section can only be used either at the end or for extensions.
Looking for options ...
Thanks !whacko wrote:
/album/*/foto/*
This one is indeed not possible. Best would be to have the servlet behind /album/* to check the URL if it contains /album/<albumname>/foto/<fotoname> and then have it to forward the request further to the foto servlet. -
Hi, I am using Tomcat 4.0.3. I am trying to map my JSP pages by giving the following code in web.xml file.
<servlet>
<servlet-name>AJSP</servlet-name>
<jsp-file>/myjsp.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>AJSP</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
But I am getting the following error when I try to start tomcat. If I remove above lines, then there is no problem.
org.xml.sax.SAXParseException: The content of element type "web-app" must match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-
mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welco
me-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-const
raint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
Thank in advance
RaviWhy would you map a jsp?
you can just add jsp files to your directories and they will be compiled at the first load...
when you update files they will be loaded also...
I can't imagine any advantage on mapping jsp files...
greetings -
Mapping JSP's to outside of the war or expanded folder
Hi there
We use resin here in my work. Resin allows in its web.xml an element like:
<path-mapping>
<url-pattern>/jsp/*</url-pattern>
<real-path>c:/resin/resin-2.1.4/apps/ucs/</real-path>
</path-mapping>
<path-mapping>This can also be used in resin.conf, amking the war more portable.
Now we are starting a migration to tomcat. But as far as I know TC doesnt not allow to have the JSP's out side of the war or the expanded war. I did a research a couple of years ago. Did it changed? Is there anyway now of mapping the jsp's of an app to an outside folder?
Thanks
Emerson CargninIf you are near one of the uk apple stores, take your ipod to the store and i'm sure they'd let you plug it in to a charger to complete the update, locations...
http://www.apple.com/uk/buy/
any decent retail store that has the ipod on demo should also be able to do this for you, staff at microanvika for instance are usually very helpful
other things to try...
anyone at work/wherever with an ipod? borrow their charger
buy a charger, try ebay for a used one -
Please Help::How to display a Map with LIsts as Keys and Values using JSTL
Hi,
I need some assistance on how to display a Map in JSP using struts or core JSTL. I have a HashMap which has a List of keys and each key maps to a value of an ArrayList.i.e I have an ArrayList of taxCodes and each taxCode maps to a value of taxDetails which is an ArrayList of details for for that particular taxCode. I have some trouble to display each taxCode then display taxDetails for each taxCode. Here is my code below:
OrderDetails.java
package orderitems;
import java.sql.*;
import java.util.*;
public class OrderDetails {
private LineOder lineOrder;
private Map lineItems;
//returns an item number, key_item, from its unique keys
public int getItemNumber(int key_item, String key_year,
String key_office,String key_client,String key_company){
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
int itmNum = 0;
* key_item a unique number for an item.
* key_year,key_office,key_client,key_company unique keys
* for each order where this key_item is taken
* from.
String select = "SELECT key_item FROM "+
Constants.WEB_TABLE +" WHERE key_item = " + key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
if(rst.next()){
itmNum = Integer.parseInt(rst.getString("key_item"));
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itmNum;
//get a list of item number(item codes)
public List getAllItemNumbers(String key_year,
String key_office,String key_client,String key_company){
List itemNumbers = new ArrayList();
LineItem itemNumber = null;
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
String select = "SELECT key_item FROM "+ Constants.WEB_TABLE +
" WHERE key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company + "'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
itemNumber = new LineItem();
itemNumber.setKey_item(Integer.parseInt(rst.getString("key_item")));
itemNumbers.add(itemNumber);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itemNumbers;
//get a list of tax codes
public List getAllTaxCodes(int key_item, String key_year,
String key_office,String key_client,String key_company){
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
ItemTax taxCode;
List taxCodes = new ArrayList();
int itemNum = getItemNumber(key_item, key_year,
key_office,key_client,key_company);
String select = "SELECT key_tax_code FROM "+
Constants.WEB_TABLE +" WHERE key_item = " + itemNum +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
taxCode = new ItemTax();
taxCode.setKey_tax_code(rst.getString("key_tax_code"));
taxCodes.add(taxCode);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return taxCodes;
/////This methode returns a Map which am trying to display in JSP
//use tax code to get tax details
public Map getItemTaxDetails(String key_year,String key_office,
String key_client,String key_company,int key_item){
ItemTax taxDetail = null;
List taxDetails = new ArrayList();
List itemTaxCodes = new ArrayList();
Map itemTaxDetails = new HashMap();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//get a list of all tax codes of an item with a
//given item number
itemTaxCodes = getAllTaxCodes(key_item,key_year,
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
String taxCode = itemTaxCode.getKey_tax_code();
String select = "SELECT tax_type,tax_value," +
"tax_limit_val FROM "+ Constants.WEB_TABLE +
" WHERE key_item = "+ key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'" +
" AND key_tax_code = '" + taxCode + "'";
rst = stat.executeQuery(select);
while(rst.next()){
taxDetail = new ItemTax();
//records to be displayed only
taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
taxDetail.setTax_value(rst.getString("tax_value"));
taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
//////other details records ommited//////////////////////////
taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
* A HashMap which has all taxCodes of an item as its keys
* and an ArrayList of taxdetails as its values.
* I return this for display in a JSP.
itemTaxDetails.put(taxCode,taxDetails);
System.out.println();
System.out.println("*********CONSOLE OUTPUT*************");//display on console
Set set = itemTaxDetails.keySet();
Iterator iter = set.iterator();
System.out.println("Key\t\tValue\r\n");
while (iter.hasNext()) {
Object taxCode=iter.next();
Object details=itemTaxDetails.get(taxCode);
System.out.println(taxCode +"\t" + details);
System.out.println("************************************");
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itemTaxDetails;
//details of an item with all its taxes
public List getAllItemDetails(String key_year,
String key_office,String key_client,String key_company){
List lineItems = new ArrayList();
List itemNumbers = new ArrayList();
Map taxDetails = new HashMap();
LineItem item = null;
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//A list of all item numbers in the declaration
itemNumbers = getAllItemNumbers(key_year,
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator itemIter= itemNumbers.iterator(); itemIter.hasNext();){
LineItem itemNum = (LineItem)itemIter.next();
int itemNumber = itemNum.getKey_item();
String select = "SELECT item_description,item_mass," +
"item_cost" +
" FROM " + Constants.WEB_TABLE +
" WHERE key_year = '"+key_year+"'" +
" AND key_office = '"+key_office+ "'"+
" AND key_client = '"+key_client+ "'"+
" AND key_company = '"+key_company+ "'"+
" AND key_item = " + itemNumber;
rst = stat.executeQuery(select);
while(rst.next()){
item = new LineItem();
item.setItem_description(rst.getString("item_description"));
item.setItem_mass(Float.parseFloat(rst.getString("item_mass")));
item.setKey_item(Integer.parseInt(rst.getString("item_cost")));
//////other details records ommited//////////////////////////
/* A HashMap of all itemTaxeCodes as its keys and an
* ArrayList of itemTaxedetails as its values
taxDetails = getItemTaxDetails(item.getKey_year(),item.getKey_office(),
item.getKey_client(),item.getKey_company(),item.getKey_item());
//item tax details
item.setItmTaxes(taxDetails);
//list of items with tax details
lineItems.add(item);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return lineItems;
public Set getOrders(String key_year,String key_office,
String key_client,String key_company){
List lineItems = new ArrayList();
Set lineOrders = new HashSet();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
LineOder lineOrder = null;
String select = "SELECT * FROM " + Constants.WEB_TABLE +
" WHERE key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company + "'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
lineOrder = new LineOder();
lineOrder.setKey_year(rst.getString("key_year"));
lineOrder.setKey_office(rst.getString("key_office"));
lineOrder.setKey_client(rst.getString("key_client"));
lineOrder.setKey_company(rst.getString("key_company"));
////list of items with all their details
lineItems = getAllItemDetails(lineOrder.getKey_year(),lineOrder.getKey_office(),
lineOrder.getKey_client(),lineOrder.getKey_company());
//setting item details
lineOrder.setItems(lineItems);
//a list of order with all details
lineOrders.add(lineOrder);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return lineOrders;
Controller.java
package orderitems;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Controller extends HttpServlet {
private Map taxDetails = new HashMap();
private OrderDetails orderDetails = null;
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String key_year = "2007";
String key_office = "VZX00";
String key_company = "DG20";
String key_client = "ZI001";
int key_item = 1;
String nextView = "/taxdetails_list.jsp";
orderDetails = new OrderDetails();
taxDetails = orderDetails.getItemTaxDetails(key_year,key_office,
key_company,key_client,key_item);
//Store the collection objects into HTTP Request
request.setAttribute("taxDetails", taxDetails);
RequestDispatcher reqstDisp =
getServletContext().getRequestDispatcher(nextView);
reqstDisp.forward(request,response);
protected void doGet(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
processRequest(request, response);
protected void doPost(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
processRequest(request, response);
taxdetails_list.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Simple Tax Detail Diaplay ::</title>
<link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
</head>
<body>
<jsp:useBean id="taxDetails" class="java.util.HashMap" scope="request"/>
<table>
<c:forEach items="${taxDetails}" var="hMap">
<tr>
<td><c:out value="${hMap.key}" /></td>
<!--td><%--c:out value="${hMap.value}" /--%></td-->
</tr>
</c:forEach>
</table>
</body>
</html>am displaying taxCodes(in this case i have VAT and ICD) fine but cant figure out how to display a list of value for each taxCode.Here is the output am getting
both in my JSP and on the console:
*******************************CONSOLE OUTPUT****************************
Key Value
ICD [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
VAT [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
Edited by: aiEx on Oct 8, 2007 6:54 AMhi evnafets,
yes i need a nested for loop.I have tried your advice but my bean properties are not found.Am getting this error:
javax.servlet.ServletException: Unable to find a value for "key_item" in object of class "java.lang.String" using operator "."
I have tried this as stated earlier in the post:I have tried to make the method getItemTaxDetails return a List and get the returned list value as taxDetails. I then tested to display this list on JSP and its displaying fine.
public List getItemTaxDetails(String key_year,String key_office,
String key_client,String key_company,int key_item){
ItemTax taxDetail = null;
List taxDetails = new ArrayList();
List itemTaxCodes = new ArrayList();
Map itemTaxDetails = new HashMap();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//get a list of all tax codes of an item with a
//given item number
itemTaxCodes = getAllTaxCodes(key_item,key_year,
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
String taxCode = itemTaxCode.getKey_tax_code();
String select = "SELECT tax_type,tax_value," +
"tax_limit_val FROM "+ Constants.WEB_TABLE +
" WHERE key_item = "+ key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'" +
" AND key_tax_code = '" + taxCode + "'";
rst = stat.executeQuery(select);
while(rst.next()){
taxDetail = new ItemTax();
//records to be displayed only
taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
taxDetail.setTax_value(rst.getString("tax_value"));
taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
//////other details records ommited//////////////////////////
taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
* A HashMap which has all taxCodes of an item as its keys
* and an ArrayList of taxdetails as its values.
* I return this for display in a JSP.
itemTaxDetails.put(taxCode,taxDetails);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
//return itemTaxDetails;
return taxDetails;
}And my JSP
taxdetails_list.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
</head>
<body>
<table>
<c:forEach var="curRecord" items="${taxDetails}" varStatus="rowCounter">
<c:choose>
<c:when test="${rowCounter.count % 2 == 0}">
<c:set var="rowStyle" scope="page" value="odd" />
</c:when>
<c:otherwise>
<c:set var="rowStyle" scope="page" value="even" />
</c:otherwise>
</c:choose>
<tr class="${rowStyle}">
<td>${curRecord.key_item}</td>
<td>${curRecord.tax_value}</td>
<td>${curRecord.tax_limit_val}</td>
</tr>
</c:forEach>
</table>
</body>
</html>I can't see where am going wrong even with your advice.Please help.
Thnx.
Maybe you are looking for
-
How do I remove unwanted applications in 10.7 ?
Sorry but I've recently migrated from system 9.0 to OS 10.7, with a brief interval at 10.4. My question is, is there no way to remove 'core' applications like Safari, AppsStore, PhotoBooth etc. NONE of which I want or need ... I have favoured applic
-
Let me walk you through everything I did and the following issues that occurred... Under Actions Wizard I chose "Optimize for Web" Then I saved the the document as an "Optimized Adobe PDF" I then had small text edits I needed to make to the document.
-
Powerbook G4 10.4.10 2GB SDRAM 1.67 GHz Final Cut Studio 5 All was okay until I stupidly ran a BT uninstaller program (don't ask) On re-start some audio drivers were missing and I eventually had to reinstall OS 10.4.1 and update back to 10.4.10. Sinc
-
Pls hlp: Oracle 8.16 and Forms/Reports 6i Install
I am currently running Oracle 8.16 on WIN2K w/o any problems. I want to install Forms and Reports 6i on same machine. Pls tell me how to correctly install Forms and Reports 6i and allow me to use current database in Oracle 8.16..
-
I am new to Macs and I have no idea how to view wmv files. When I receive them, they are grayed out and they don't open when I click on them. Any help will be most appreciated!