Urgent: array on jsp
hi
can you please help me. i want to create an array, i get my data which is stored on the array on mysql database. here is my code:
<% String[] subjects = {rsstudents.getObject("subj1"), rsstudents.getObject("subj2"), rsstudents.getObject("subj3"), rsstudents.getObject("subj4"), rsstudents.getObject("subj5")}; %>
its giving me an error which says
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\home_jsp.java:138: '}' expected
i will glad if you can help
this is bcas u have not typecasted it to string
do it this way
<%
String[] subjects = {(String)rsstudents.getObject("subj1"), (String)rsstudents.getObject("subj2"), (String)rsstudents.getObject("subj3"), (String)rsstudents.getObject("subj4"), (String)rsstudents.getObject("subj5")};
%>
Similar Messages
-
URGENT: Passing Array from JSP to a Stored Procedure
Hi,
Can some one please help me understanding how can I pass array from JSP page to a stored procedure in database.
Thanks in advance.
JatinderThanks.
I tried ArrayExampla.java and was successful in passing array values to the stored database procedure.
How can I use this class in JSP? Like I have first JSP where in I will collect input from the user and then submit it to the second JSP - that needs to call the ArrayExample.java to pass the values as array to the database.
How should I call this java code in my second JSP?
Thanks in advance. -
How to get the values of an Array using JSP Tags
Hey guys,
I need some help. I've splited a String using
fn:split(String, delim) where String = "1,2,3,4" and delim is ,
This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
Any help would be highly appreciated
ThanksThe JSTL forEach tag.
In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
<c:set var="list" value="1,2,3,4"/>
<c:forEach var="num" items="${list}">
<c:out value="${num}"/>
</c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string. -
Multi-dimensional Arrays in JSP
Hello,
i am writing my first lines of JSP Code and need some help. what is up with Multi-dimensional Arrays in JSP? Is it possible in JSP? I tried to realise it like in JavaScript, without success.
So, please help me :)
MarkHello,
i am writing my first lines of JSP Code and need some
help. what is up with Multi-dimensional Arrays in
JSP? Is it possible in JSP? I tried to realise it
like in JavaScript, without success.
So, please help me :)
Mark -
Assigning javascript array with jsp array
hi,
I have a jsp page where I have a array in jsp. I want to assign the values to an javascipt array. how can I do that?
the reason why I want to do this is for a perticular problem I am facing in javascript. that is....
I have a text box in my jsp page, I want the value entered in that box to be checked (whether it exists ) against a hidden string which has some value. I want that hidden string not to be shown to the user even on seeing the html source. that is why I want these values to be stored and checked against a array object of javascript.
any suggestion is appreciated
Thanks
AshutoshHai asutoshdash
if you dont mind of viewing code u can use this else dont use, its not matters weatehr user will see you code or not if the user is professiona then its a big issue normal users not think of is for this dont send valuable infos like password etc to client u may send usernames
ok to create a java array to javascript array do this (i took example of db to array ) write this inside <script> <%codes here%> </script>
var aUsername =new array();
<%
int i=0;
while (rs.next())
%>
aUsername[<%= ++i%>] = "<%= rs.getString("User_Name")%>";
<%
%>thats it use this array where ever you want in your client side(javascript ) usage
hope this will help you
archi -
How to Display string array in jsp page using netui-data:repeater tag ??
hi,
I am trying to display a string array in a table using the netui-data:repeater tag.
I have to use a page flow controller Array(1 Dimensional) to be displayed in the jsp.
Can any one tell me how to print the array in a table of 3rows & 5 columns.
Here is the code on which I am crrently working on.
<netui-data:repeater dataSource="{pageFlow.strWorkObject_Array}">
<netui-data:repeaterHeader>
<table cellpadding="4" border="1" class="tablebody">
</netui-data:repeaterHeader>
<netui-data:repeaterItem>
<tr>
<td><netui:label value="{container.item}" >
</netui:label></td>
<td><netui:label value="{container.item}">
</netui:label></td>
<td><netui:label value="{container.item}">
</netui:label></td>
</tr>
</netui-data:repeaterItem>
<netui-data:repeaterFooter>
</table>
</netui-data:repeaterFooter>
</netui-data:repeater>weblogic.developer.interest.workshop
Mansoor Naseem wrote:
I would like to know where the pageflow newsgroup is.
These are all the groups in weblogic.developer.interest:
weblogic.developer.interest.60beta.* (5 groups) weblogic.developer.interest.management
weblogic.developer.interest.61beta.* (2 groups) weblogic.developer.interest.misc
weblogic.developer.interest.clustering.* (1 group) weblogic.developer.interest.performance
weblogic.developer.interest.commerce weblogic.developer.interest.personalization
weblogic.developer.interest.ejb.* (3 groups) weblogic.developer.interest.portal
weblogic.developer.interest.environment weblogic.developer.interest.rmi-iiop
weblogic.developer.interest.jdbc weblogic.developer.interest.security
weblogic.developer.interest.jms weblogic.developer.interest.servlet
weblogic.developer.interest.jndi weblogic.developer.interest.tools
weblogic.developer.interest.jsp weblogic.developer.interest.weblogicenterprise
MN -
Two dimensional array in JSP with struts
Is it possible to use two dimensional array in an web application
based on struts. I am using JSP and to get data from two dimensional
array im using
property = "array[0][0]";I read on the internet that bean utils does not support two dimensional array?
I have a table like spreadsheet with 30 rows and 20 columns and i was
planning to use two dimensional array? is there any other way to get
this stuff done easily?
any ideas welcome.HI ,
i have the same problem you had
did you get any solution for this?
if so you can help me out -
Looping through javabean array in jsp?
Hello,
In my servlet, I created an ArrayList of objects and pass these to a jsp page using:
req.setAttribute("bean", uploadList);
The ArrayList contains objects of the FileBean class, with a getIndex, and getDate methods.
Could any possibly demonstrate how to loop through the ArrayList in the jsp and display the FileBean object values in a html table?
To display the values of a javabean in jsp pages I normally have to use for example, requestScope.bean.getMethod();
ThanksNo, that would be requestScope.bean.attributename, if your getter method has the same name as the attribute you are getting.
To loop through an array you have to use the c:forEach tag. Check google for "jstl foreach example", there are loads of examples. -
Calling multidimensional array in JSP into other JSP
hello friends,
nice to c good replies over here...so i want to post my problem in JSP using multi-dimensional
array..
One JSP contains mutli-dimensional array and i want to call this JSP into the other JSP in which i can use the values of that array.i think the jsp include directive should be suitable for you. the variables from the included jsp can be used in the jsp which is including it.
<%@ include file="whatever.jsp" %> -
Urgent array help needed! come get some duke points
this program keeps track of rentals for a shop. Other methods and classes not shown (like Customer, Transaction classes) are also in this program. Every item (created with a constructor in Item class) can hold an array of up to 20 transactions; part of a Transaction object is a rental total, based on a number of rental days * specific rental price for that item rented (backhoe, edger, etc.) If the user presses "t" for total amount of transactions, the following method is called, which calls the getTotalPrice() in another class called Item. My problem here is that even if I enter in transaction amounts, when I press "t", the program just quits, not producing the report and returning me to the main class. I have been over it with the debugger and I am still lost. Below is some selected code; I hope it is sufficient. Please let me know if I need to put up more
//main
String input = JOptionPane.showInputDialog(null, "Enter a rental transaction (x)" +
"\nAdd a customer (c)" +
"\nAdd an item (i)" +
"\nReport on a specific item (r)" +
"\nReport on total dollar amounts of rentals for all items (t)" +
"\nReport on total rentals for a specific customer (s)" +
"\nStrike cancel to exit from the program");
//big huge while
while (input != null){
if (input.equals("x")){
rentalTrans();
}//if
if (input.equals("c")){
addCustomer();
}//if
if (input.equals("i")){
addItem();
}//if
if (input.equals("r")){
specificItemReport();
}//if
if (input.equals("t")){
allItemReport();
}//if
if (input.equals("s")){
customerReport();
}//if
input = JOptionPane.showInputDialog(null, "Enter a rental transaction (x)" +
"\nAdd a customer (c)" +
"\nAdd an item (i)" +
"\nReport on a specific item (r)" +
"\nReport on total dollar amounts of rentals for all items (t)" +
"\nReport on total rentals for a specific customer (s)" +
"\nStrike cancel to exit from the program");
//allItemReport()
public static void allItemReport(){ //menu item t
Item temp = null;
for (int index = 0; index < items.length; index++){
temp = items[index];
}//for
JOptionPane.showMessageDialog(null, "Total rental transactions to date amount to: $" + temp.getTotalPrice());
//Item Class
public String getTotalPrice() {
double total = 0;
String output = "";
for (int i = 0; i < trans.length; i++) {
if (trans[i] == null) {
if (i == 0) {
output = "There are currently no transactions.";
}// if
break;
}// if
else{
total += getPerDayRentalPrice();
}//else
}// for
output+= total;
return output;
}//getTotalPriceDon't flag your questions as urgent. It's rude. Also don't think that waving with a couple of worthless Dukes is going to get you better/quicker help.
The reason I respond to your question is because you have explained your problem well and used code tags.
Try this:class Main {
public static void main (String[] args) {
String message = "Enter a rental transaction (x)\nAdd a customer (c)" +
"\nAdd an item (i)\nReport on a specific item (r)\nReport on total "+
"dollar amounts of rentals for all items (t)\nReport on total rentals"+
" for a specific customer (s)\nStrike cancel to exit from the program";
String input = JOptionPane.showInputDialog(null, message);
while(input != null){
if (input.equals("x")) rentalTrans();
else if (input.equals("c")) addCustomer();
else if (input.equals("i")) addItem();
else if (input.equals("r")) specificItemReport();
else if (input.equals("t")) allItemReport();
else if (input.equals("s")) customerReport();
else System.out.println("Invalid option!");
input = JOptionPane.showInputDialog(null, message);
System.out.println("Bye!");
// the rest of your methods ...
} -
Passing An Array trough JSP pages
Hello there, what i am trying to do here is pass an array that i have created in one.jsp to another.jsp.
So if i want to pass a single variable say Long (for example) i would do something like that:
one.jsp
Long pairId = new Long(15);
session.setAttribute("pair", pairId);and to retrive it from another.jsp
Long pairId = new Long(session.getAttribute("pair").toString());Now instead of Long pairId if i create a Long[] pairArray and want to move it from one.jsp to another.jsp what should i do? Please let me know if this is possible and if not, please suggest an alternative way to go arround this problem.actually i didnt read what you write properly, so if i can do it, how should i do it?
if i do something like that
one.jsp
String[] lArray =...
session.setAttribute("pair", langArray);and try ratreaving it from another.jsp like that:
String[] langArray = session.getAttribute("langArray").toString();i am getting the following error:
C:\Programs\internet\jakarta-tomcat-5.0.28\work\Catalina\localhost\myapp\org\apache\jsp\resources\questionsmanager\addQustion_005fSubmit_jsp.java:66: incompatible types
found : java.lang.Object
required: java.lang.String[]
String[] langArray = session.getAttribute("langArray");
^
1 error
this means that the array is casted to Object and i need to cast it buck to a string array.... But how am i suppose to do that??? -
I cant pass an array from JSP to Servlet
I have a JSP which creates a table when it is loaded doing a query on a database and showing the content of the result set.
The data showed are some items' names and at the end of each row there is a text field where the user can write the quantity of each item to buy.
I need to send to a servlet the name and the quantity of each item with a quantity value > 0.
This is what I think to do:
in the text field I've put an onChange event which calls a javascript function, the function inserts the item and the quantity inside an array if the quantity is > 0, removes the item if the quantity is <= 0.
The submit button calls another function which put the array in the session
session.setAttibute("daAcquistare",daAcquistare);
daAcquistare is my array created in the JSP
var daAcquistare = new Array();
Inside the servlet I don't know how to take that array since if I do like this
String[] ingrediente = new String[i*2];
HttpSession session = request.getSession();
ingrediente = session.getAttribute("daAcquistare");
I obtain "Cannot convert from Object to String[]"
How can I do to have that array inside the servlet?Thankyou for your reply.
This is my form:
<form name="rimanenze" action="VerificaRimanenze" method="post">
<table width="650" border="0" cellpadding="6">
<tr>
<td width="25%"><b>Ingrediente</b></td>
<td width="25%"><p align="center"><strong>Unit� di misura</strong></p></td>
<td width="20%"><p align="center"><strong>Disponibilit�</strong></p></td>
<td width="20%"><p align="center"><strong>Soglia</strong></p></td>
<td width="10%"><p align="center"><strong>Acquista</strong></p></td>
</tr>
<% rs = IngrController.getInEsaurimento();
while(rs.next()) { %>
<tr>
<td><%= rs.getString("nome") %> </td>
<td><%= rs.getString("unitaDiMisura") %></td>
<td><%= rs.getString("disponibilita") %></td>
<td><div align="center"><%= rs.getString("soglia") %></div></td>
<td><div align="center"><input type="text" id="ingrediente<%= i %>" name="<%= rs.getString("nome") %>" value="0" onChange="selezionato(this)" /></div></td>
</tr>
<%i++; } %>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><input type="hidden" name="totale_selezionati" value="0"/> </td>
<td><input type="submit" name="acquista" value="Acquista" /></td>
</tr>
</table>
</form>and this is the servlet's doPost method
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int i = Integer.parseInt(request.getParameter("totale_selezionati")); //nuber of item with quantity value > 0
int j = 0, aux = 0; //j counts the number of items with quantity > 0 found, aux loops on each item id
String[] ingrediente = new String;
while (j < i) { //while stops when number of item with quantity value > 0 found is the same of the known number of those items
if(Integer.parseInt(request.getParameter("ingrediente"+aux)) > 0) {
ingrediente[j] = request.getParameter("ingrediente"+aux); //takes the attribute value of the item, how to thake the name too?
j++;
aux++;
else
aux++;
IngrController.aggiungiIngredienteMagazzino(ingrediente,i);
RequestDispatcher dispatcher = request.getRequestDispatcher("/verificarimanenze.jsp");
dispatcher.forward(request, response);
I can't use the items' names to loop on the form because the form is dinamically generated, I need to use the id attribute for that and then, take the name and value in the servlet... I can only take the value, I don't know how to take the name.
Edited by: Kumidan on Jul 24, 2008 9:16 AM
modified an instruction inside the while in the doPost method. -
How to pass an Array to jsp:param
Hi,
I am trying to find out how to pass an array to a jsp:param tag abnd then retrieve
the values in the next page. Please help soon. Thanks
Here's my code - Assume the books array has more than 1 value
String[] books = request.getParameterValues("book");
<jsp:include page="<%=contentPage%>" flush="true">
<jsp:param name="bookSelected" value="<%= books %>" />
</jsp:include>
The 'contentPage' takes me to the next page where I have the following to retrieve
the value of 'bookSelected'
String[] bookSelected = request.getParameter("bookSelected");
I tried accessing the array like this
if(bookSelected.equals("book1"))
but did not succeed.
I tried accessing the array in a loop but it did not work. Here's what I tried.
<jsp:include page="<%=contentPage%>" flush="true">
<%for (int i = 0; i<books.length; i++){
%>
<jsp:param name="bookSelected" value="<%= books %>" />
<% } %>
</jsp:include>
Hi
tell me how you redirect from __confirmdelete.jsp:__ to deleteServlet.java..
and post detail code of __confirmdelete.jsp:__ -
Display jpeg byte array with JSP !!
I am new in JSP area so maybe I ask a easy question !!
First, on the server side:I use a C++ program to stream sequence jpeg data out(FF D8 ~ FF D9).
Second, on the client side:I use jsp to open a socket and read
data to a byte array.
Can anyone tell me how to display the jpeg array on browser one by one ?um... like video frames, or just a single image? I wouldn't really use JSP for that, I'd use a servlet, set the content-type to image/jpeg and just write out the bytes. Unless you are talking about displaying the bytes themselves, in which case, a JSP page would be better. If it's video frames, I'm not sure how to have the browser do that, since most no longer support server push.
-
Any help with this will be really appreciated. I'm new to programming.
If I search for an ssn in a database, I want to view all records relating to that ssn. However, I am getting all the records in the table.
eg.
at the prompt for ssn, let's say I enter 111111111
I would like to see
111111111 abc xyz etc
111111111 pdg ppp etc
however, I am getting
000000000 utt tui etc
111111111 tug etg etc
How do I make limit the search to the ssn I want?
The related code is below.
Thanks.
Java Code
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
if (checkLoginSessionPresent(request, response)) {
loadTable("/esoladm/TaxView.jsp", request, response);
else {
checkLoginSessionRedirect("/esoladm/ESOLAdminMain.jsp", request, response);
JSP Code
<% while (MyTaxSuppress != null) { %>
<% String sPlanCode = MyTaxSuppress.getPlanCode(); %>
<% String sSSN = MyTaxSuppress.getSSN(); %>
<% String sTaxYear = MyTaxSuppress.getTaxYear(); %>
<% String sDistCode = MyTaxSuppress.getDistCode(); %>
<% double sGrAmount = MyTaxSuppress.getGrAmount(); %>
<% String sStmtType = MyTaxSuppress.getStmtType(); %>
<% boolean bNewSuppress = MyTaxSuppress.getNewSuppress(); %>
<% String rowID = sPlanCode; %>
<% rowID += sSSN; %>
<% rowID += sTaxYear; %>
<% rowID += sDistCode; %>
<% rowID += sStmtType; %>
<% rowID += sGrAmount; %>
<% System.out.println( "Do While lp exiti" + rowID);%
<% if (bNewSuppress) { %>
<% out.println( "<TD> %>
<% <img BORDER='0' SRC='/esoladm/ESOLNew2.gif' %>
<% ALT='' WIDTH='50' HEIGHT='20'> </TD >"); %>
<% } else { %>
<% out.println( "<TD></TD>"); %>
<% } %>
<TD><%= sPlanCode %></TD>
<TD><%= sSSN %></TD>
<TD><%= sTaxYear %></TD>
<TD><%= sDistCode %></TD>
<TD><%= sGrAmount %></TD>
<TD><%= sStmyType %></TD>
<TD><input TYPE="checkbox" name="<%=rowID %>" ></TD>
<% MyTaxSuppress = MySuppressTaxList.getNext(); %>
<% } // end of while loop %>I don't see anywhere in your code where you conditionally output a tuple from your database. You seem to be outputting everything.
Maybe you need:
<% if (sSSN==input_value){ %>
<TD><input TYPE="checkbox" name="<%=rowID %>" ></TD>
<% } %>
Maybe you are looking for
-
XML File to SAP R/3 using SAP XI
Hello Everyone, I'm hoping someone has done this scenario and can provide a step by step example for me. The scenario I have is as follows: -- An XML file is placed manually on a UNIX SAP Server -- SAP XI should, once the file is placed on the serve
-
Camera Raw 5.5 VS Adobe Lightroom (color correction)
Hi, does somebody know if discarding the advantage of making layers of Photoshop, is the Adobe Lightroom color correction controls superiors to the CameraRaw PS Interface correction controls ??? I mean for color correction purposes is Adobe Lightroom
-
First post - Asking for advice
Hi all, For work and personal reasons I have decided to try to learn Java. I don't have much experience with computer languages - just the BASIC I learnt at school 20 years ago and messing around with VBA in Excel. To start with I'd just like to ask
-
ISupport - Create Service Request HTML form
Hello, Is there a way to view the query executed by the Create Service Request html form? I need to view the query executed to fetch the Contact Information when creating a Service Request. TIA
-
Debugging the Standard Extractor
Hi , I have issue with delta loads for one of the Standard extractors. Need to debugg and see where is the issue. If it is full load i know we can do from RSA3. We have option to debugg delta load in RSA3. But it is grayed out. Thanks in advance. Rgd