How to get attribute from select
Hello
I have a problem getting the value from my select-field from my form in my servlet.
I can get the values from the textareas and the textfileds but not from my select. If i mail the same form i get the selected value, but not when i try to get this in my servlet.
To get the other values i use:
String subcategory = (String) request.getAttribute("subcategory");
Is there any other way to get the values from select (or radiobuttons) ?
don't you think you should use request.getParameter("XXX")?
And if your can select multiple items , then use request.getParameters("SSS"). Note that this method return arrray of String.
Similar Messages
-
How to get attribute from xml file
I managed to grab all the info from xml, except the "url" attribute in <image type="poster" url="" size="mid" .../>. Any ideas?
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.net.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class XmlParser {
ArrayList<Movie> myMovies;
Document dom;
public XmlParser(){
//create a list to hold the movie objects
myMovies = new ArrayList<Movie>();
public void runExample(String adr, String tagName) {
parseXmlFile(adr);
parseDocument(tagName);
printData();
private void parseXmlFile(String adr){
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
URL xmlUrl = new URL(adr);
InputStream in = xmlUrl.openStream();
dom = db.parse(in);
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
private void parseDocument(String tagName){
//get the root elememt
Element docEle = dom.getDocumentElement();
//get a nodelist of <movie> elements
NodeList nl = docEle.getElementsByTagName(tagName);
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the movie element
Element el = (Element)nl.item(i);
//get the Movie object
Movie mov = getMovie(el);
//add it to list
myMovies.add(mov);
* I take an movie element and read the values in, create
* an Movie object and return it
* @param movE
* @return
private Movie getMovie(Element movE) {
String title = getTextValue(movE, "original_name");
String year = getTextValue(movE, "released");
String imdbId = getTextValue(movE, "imdb_id");
double score = getDoubleValue(movE, "score");
String overview = getTextValue(movE, "overview");
String poster = movE.getAttribute("url");
Movie mov = new Movie(title, year, imdbId, score, overview, poster);
return mov;
private String getTextValue(Element ele, String tagName) {
String textVal = null;
NodeList nl = ele.getElementsByTagName(tagName);
if(nl != null && nl.getLength() > 0) {
Element el = (Element)nl.item(0);
textVal = el.getFirstChild().getNodeValue();
return textVal;
* Calls getTextValue and returns a int value
* @param ele
* @param tagName
* @return int
private int getIntValue(Element ele, String tagName) {
//in production application you would catch the exception
return Integer.parseInt(getTextValue(ele, tagName));
* Calls getTextValue and returns a double value
* @param ele
* @param tagName
* @return double
private double getDoubleValue(Element ele, String tagName) {
return Double.parseDouble(getTextValue(ele, tagName));
* Iterate through the list and print the
* content to console
private void printData(){
System.out.println("Total Movies: " + myMovies.size());
Iterator it = myMovies.iterator();
while(it.hasNext()) {
System.out.println(it.next().toString());
public static void main(String[] args){
//create an instance
XmlParser xp = new XmlParser();
//call run example
xp.runExample("http://api.themoviedb.org/2.1/Movie.search/en/xml/apikey/Fight+Club+1999", "movie");
}Here is the example xml file I used
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<opensearch:Query searchTerms="Fight Club 1999"/>
<opensearch:totalResults>1</opensearch:totalResults>
<movies>
<movie>
<score>8.383284</score>
<popularity>3</popularity>
<translated>true</translated>
<adult>false</adult>
<language>en</language>
<original_name>Fight Club</original_name>
<name>Fight Club</name>
<alternative_name>El Club de la Lucha</alternative_name>
<type>movie</type>
<id>550</id>
<imdb_id>tt0137523</imdb_id>
<url>http://www.themoviedb.org/movie/550</url>
<votes>62</votes>
<rating>8.4</rating>
<certification></certification>
<overview>A lonely, isolated thirty-something young professional seeks an escape from his mundane existence with the help of a devious soap salesman. They find their release from the prison of reality through underground fight clubs, where men can be what the world now denies them. Their boxing matches and harmless pranks soon lead to an out-of-control spiral towards oblivion.</overview>
<released>1999-09-16</released>
<images>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-original.jpg" size="original" width="1000" height="1500" id="4bc908ab017a3c57fe002f75"/>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-mid.jpg" size="mid" width="500" height="750" id="4bc908ab017a3c57fe002f75"/>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-cover.jpg" size="cover" width="185" height="278" id="4bc908ab017a3c57fe002f75"/>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-thumb.jpg" size="thumb" width="92" height="138" id="4bc908ab017a3c57fe002f75"/>
<image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-original.jpg" size="original" width="1280" height="720" id="4bc908ab017a3c57fe002f71"/>
<image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-poster.jpg" size="poster" width="780" height="439" id="4bc908ab017a3c57fe002f71"/>
<image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-thumb.jpg" size="thumb" width="300" height="169" id="4bc908ab017a3c57fe002f71"/>
</images>
<version>73</version>
<last_modified_at>2010-09-11 14:33:06</last_modified_at>
</movie>
</movies>
</OpenSearchDescription>pvujic wrote:
Thanks, but how can I "fetch" the url from the image element?You've got to first get to the image element. But based on what you've posted though, with a little more coding, you should be able to succeed. Just give it a try! :) -
How to get filename from selected directory
Helle experts,
I've a string variable from a directory with following content:
G:\SAP_R3_MRSS\SAP_MRS\FAVORIT.PDF
now I just want to select the filename, in this case FAVORIT.TXT
How can I do this ? The directory/filename may vary.
Some ideas ?
Thanks
GerdEric's split is probably the best way, but if you need a way to break the path into drive, path, and file, you could use a standard, well-used regular expression:
PROGRAM zzfile.
DATA:
g_regex TYPE string VALUE '\b((?#drive)[a-z]):\\((?#folder)[^/:*?"<>|\r\n]*\\)?((?#file)[^\\/:*?"<>|\r\n]*)',
g_path_file TYPE string VALUE 'G:\SAP_R3_MRSS\SAP_MRS\FAVORIT.PDF',
g_drive TYPE string,
g_path TYPE string,
g_file TYPE string.
FIND FIRST OCCURRENCE OF REGEX g_regex IN g_path_file SUBMATCHES g_drive g_path g_file IGNORING CASE.
IF sy-subrc = 0.
* WRITE g_drive.
* WRITE g_path.
WRITE g_file.
ENDIF. -
How to get fieldnames from Select * query ?
How can I get the fieldnames returned with a SELECT * query ?
When I use GetFieldName or GetFieldOriginalName I only get fieldnames of "*".You should use the fields collection, in the OraDynaset object.
All you need to do is :
for i = 0 to Recordset.Fields.Count -1
debug.print Recordset.Fields(i).name
debug.print Recordset.Fields(i).OriginalName 'this will print the field's name before an alias
next i -
How-to get attributes from one JSF page redirected to another?
How do I send information from one JSF page when the navigation rule redirects it to another?
When JSF navigation does a forward I can use request.setAttribute() in the from-page and then use request.getAttribute() in the to-page, but this doesn't work with <redirect/>.
Regards,
Al MalinThe process scope in ADF Faces solves this. See:
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.3/state/content/navId.4/navSetId._/vtTopicFile.adffacesguide%7Cdevguide%7CcommunicatingBetweenPages%7Ehtml/ -
How to get event from selected JTable row
Whenever a JTable row is selected, i want to get an event to get the row index of the selected row and read the row data. Which listenere do i have to implement and where is the correspoinding addXXXListener() method in JTable?
here ya go...
<table>.getSelectionModel().addListSelectionListener(...);Josh Castagno
http://www.jdc-software.com -
How to get attribute from value ?
Hello experts,
I've following problem:
DATA: lv_cell TYPE REF TO data.
DATA: contact type BU_CONTACT_CHAR.
lv_cell = r_param->value. 'lv_cell contains 1
'now i want to give this paramter to another variable in order to start a fm
move lv_cell to contact. '=> retunrs error.
call fm...
How can I give this value to this paramter ?
Thanks
GProblem solved:
we have to de-refrende the object
and then move it to a vriable.
DATA: lv_cell TYPE REF TO bu_contact.
DATA: contacti type bu_contact.
move lv_cell->* to contacti. -
How to get attribute value from standard page ?
Hi,
How to get attribute value from standard page ?
String str = (String)vo.getCurrentRow().getAttrbute("RunId");
But this value is returning a null value ....
Can anyone help me to get this attribute value which is actually having a actual value .getCurrentRow() would always return null if no setCurrentRow() is used.
Please check the page design and understand how many rows of VO are there. You can also use the following to get the row:
vo.reset();
vo.next();
Regards
Sumit -
How to get the default selection color from JTable
Hi, there,
I have a question for how to get the default selection color from JTable. I am currently implementing the customized table cell renderer, but I do want to set the selection color in the table exactly the same of default table cell renderer. The JTable.getSelectionBackgroup() did not works for me, it returned dark blue which made the text in the table unreadable. Anyone know how to get the window's default selection color?
Thanks,
-JennyThe windows default selection color is dark blue. Try selecting any text on this page. The difference is that the text gets changed to a white font so you can actually see the text.
If you don't like the default colors that Java uses then use the UIManager to change the defaults. The following program shows all the properties controlled by the UIManager:
http://www.discoverteenergy.com/files/ShowUIDefaults.java
Any of the properties can be changed for the entire application by using:
UIManager.put( "propertyName", value ); -
How to get string from jtextpane along with its attributes
sir,
How to get string from jtextpane along with its attributes
i,e font,size,style,color etc.
please help me out.
my mail id is [email protected]JTextPane extends JTextComponent
JTextComponent.getDocument()
a Document is a set of Element, see Document.getRootElements(). Each Element has attributes, stored within an AttributSet object see Element.getAttributes()
a Document can also be rendered as a String, see Document.getText( offest, length ), use it with 0 and Document.getLength() as parameters. -
How to get file from server while click on link
Hi,
i created on link and i gave one server path to select file from server but while clickinng on link it no displaying any thing.
following is the Destination url that i gave for the item.
/u08/app/appvis/xxex/inst/xxex_apps/xxrbe/logs/appl/conc/log/
please tell me how to get file from server while click on link.Ok I got your requirement now.
If you are getting file names from view attribute then you should not be adding destination URI property for the link.
Instead you can use OADataBoundValueViewObject API.
Try below code in your controller processRequest method:
I am assuming that you are using classic table.
Also in below example it considers OAMessageStyleText and you can replace it with link item if you want.
OATableBean tableBean =
(OATableBean)webBean.findChildRecursive("<table item id>");
OAMessageStyledTextBean m= (OAMessageStyledTextBean)tableBean.findChildRecursive("<message styled text in table item id>");
OADataBoundValueViewObject tip1 = new OADataBoundValueViewObject(m, "/u08/app/appvis/xxex/inst/xxex_apps/xxrbe/logs/appl/conc/log/"+"<vo attr name which stores file name for each row>");
m.setAttributeValue(oracle.cabo.ui.UIConstants.DESTINATION_ATTR, tip1);
Regards,
Sandeep M. -
ADF dynamic ViewObject based on query. how to get attributes?
hi.
i have an read-only view object based on query like this:
SELECT :func(:paramm) as EMP_SAL from dual
and set :func & :paramm parameter by vo.setNamedWhereClauseParam(..) function.
but i couldn`t get EMP_SAL attribute after executeQuery command.
in another case i would set new whole Query by vo.setQuery(..) but the problem exists.
please help me. how to get attribute in such vo objects!
thanks!
Morena!thanks to Quick reply!
i seek into code and found a uninitialized Parameter in view object. error has gone after correct the problem!
and now could get the attribute value.
thanks so much!
/\/\ o r e n a! -
Get ID from selected row in data table
Hi!
Does someone know how to get ID from row on which I click a button or link?
getRowData() doesnt work!
Or any other method in jsp or just something to get the ID from selected row?
Thanks!!!Hi,
I have a table with 3 columns, where column 1 represents the key, column 2 represents the data and column 3 displays the "details"-button. If you use
String key =(String)outputText1.getValue();
the variable key contains the key value of the row of the column in which the "details"-button was clicked. (outputText1 is the Output Text field of the first column).
Problem with this is that the key Value must be displayed in the table but maybe it works if the OutputText Field is not rendered, too. If anyone has another (maybe nicer) solution for the problem i would be pleased to see it here. -
How to get value from list item
Hi all,
How to get value from list item?
I have a problem with the List Item object
in the Oracle forms.
How can I retrieve the selected item from
a list ?
I didn't find any function like 'list.GET_
SELECTED_ITEM()'...
thanks
BalaHello,
You get the value as for any other Forms item:
:value := :block.list_tem ;Francois -
How to get id of selected Tab in WebDynpro abap
HI,
How to get id of selected Tab in WebDynpro for abap? THANKS!Hi,
In the action method for onSelect try using,
DATA:
lv_select_tab type string. "Selected tab value
DATA:
lt_events type WDR_EVENT_PARAMETER_LIST,
ls_events type WDR_EVENT_PARAMETER.
field-symbols: <fs_value> type any. "Attribute value in events table
lt_events = wdevent->parameters.
read table lt_events into ls_events with key name = 'TABSTRIPID'.
if sy-subrc eq 0.
assign ls_events-value->* to <fs_value>.
if sy-subrc eq 0.
lv_select_tab = <fs_value>. "Tab selected
endif.
endif.
Hope it helps!
Regards,
Radhika,
Maybe you are looking for
-
Text Size When Printing Comments Different Than On-Screen
Hello. We are supporting an end-user with an unusual problem. They are able to make sticky comments fine and adjust the font size on screen. However, when this user goes to print either to a physical printer or a PDF, the font size of the comment
-
Listing row length and count of rows
Hi, I am trying to write a piece of code to fetch number of rows grouped monthly and running out of ideas, please help .. here is my requirement. I have a flat file which contains table names and I need to query for the date column from those table,
-
I transferred pages, keynote and photoshop from my old white macbook to my new macbook pro through the use of a hardrive. At first the applications came up as question marks on the dock and clicking on them had no response. I then tried transferring
-
How to open a Word document formatted as .wps
a friend sent an e-mail attachment composed in Word, using template features. It arrived with a .wps file extension. I can't open this, either in pages,keynote or numbers. I tried text-edit also to no avail. I tried changing the file extension to .pa
-
Osx 10.4.11 - can't connect to the server
Hi All- suddenly all of my Apple applications that connect to the internet are no longer able to connect. Safari, iTunes Store, software update, dashboard widgets are all unable to successfully connect to the internet. What is weird is that Firefox,