How to get DBconnection from a custom servlet
Hi all:
In my JHeadstart Struts application, if we will using javascript to call a custom servlet program when some html event occur,
than how can we get db connection in our Servlet because we need get some database data through this Servlet,
we hope this Servlet can share dbconnection pool with JHeadstart that is consider for performance issue.
thanks a lot !
Ting Rung,
JHeadstart is based on the Model-View-Controller (MVC) principle. This means that the Model layer is responsible for communication with the database (and thus database connection pooling). Accessing the database directly from a JSP or Servlet is against the principles of MVC. JHeadstart uses BC4J as the technology to implement the model layer. By going through an BC4J Application Module to do some database action (for example calling a stored procedure as you mentioned in another thread) you automatically get the database connection pooling.
So, in the JHeadstart philosophy, we do not access the database from a servlet, instead we would do the following:
- write a method on the BC4J app module that performs the database action
- add a method to the apporpriate handler that calls this AM method
- write a custom Struts action that calls the handler method
Having said this, nobody will stop you from doing database access in a servlet. But JHeadstart might not be the right choice for you if you do not want to stick with the principles of MVC.
Here is a link that provides you with some more background information about MVC, may be it can help you deciding what the best approach for your application is:
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html
You can also "google" on model-view-controller if you like.
Steven Davelaar,
JHeadstart Team.
Similar Messages
-
How to get an ArrayList Object in servlet from JSP?
How to get an ArrayList Object in servlet from JSP?
hi all
please give the solution for this without using session and application...
In test1.jsp file
i am setting values for my setter methods using <jsp:usebean> <jsp:setproperty> tags as shown below.
After that i am adding the usebean object to array list, then using request.setAttribute("arraylist object")
---------Code----------
<jsp:useBean id="payment" class="com.common.PaymentHandler" scope="request" />
<jsp:setProperty name="payment" property="strCreditCardNo" param="creditCardNumber" />
<%-- <jsp:setProperty name="payment" property="iCsc" param="securityCode" /> --%>
<jsp:setProperty name="payment" property="strDate" param="expirationDate" />
<jsp:setProperty name="payment" property="strCardType" param="creditCardType" />
<%--<jsp:setProperty name="payment" property="cDeactivate" param="deactivateBox" />
<jsp:setProperty name="payment" property="fAmount" param="depositAmt" />
<jsp:setProperty name="payment" property="fAmount" param="totalAmtDue" /> --%>
<jsp:useBean id="lis" class="java.util.ArrayList" scope="request">
<%
lis.add(payment);
%>
</jsp:useBean>
<%
request.setAttribute("lis1",lis);
%>
-----------Code in JSP-----------------
In testServlet.java
i tried to get the arraylist object in servlet using request.getAttribute
But I unable to get that arrayObject in servlet.....
So if any one help me out in this, it will be very helpfull to me..
Thanks in Advance
EdwardHi,
Im also facing the similar problen
pls anybody help..
thax in advance....
Litty -
How to get username from customer email id.
Hi experts,
How to get username from customer email id.I am using transaction XD02.
I would be thankful for your kind replies .
Regards,
Sachin HadaHi sachin,
Re: Email id field
Regards,
Sravanthi -
How to get hostname from targetlist in custom deployment procedure?
When I make a simple procedure with a phase that will loop through a procedure hostname list
and a hostcmd or directive inside that will use the hostname ex change a configuration file. How to get hostname from the hostname targetlist?
I would rather not use $(hostname) or similar function if I can get the hostname from the target list.
Edited by: user476601 on 2012-09-06 05:59I have tried that and cannot get it to work.
I have tried to make a procedure with:
parameter
- parallel fase
- step directive with hostname parm based on simple sh script (echo $hostname)
- map hostname setvalue %TargetName%
In a hostcmd step you cannot access %TargetName% directly
it doesn't work. Please come with an example if you have tried it.
/René -
How to get data from PDF form?
PDF forms can send data in url like GET or POST method. Is it possible to get data from url, like in PHP http://sever/file.php?item1=value1&item2=value2&item3=value3
In APEX url have specific construction and I don't know how to get value of items (1...3)
Please let me help to find simple method of geting data from URL.
Best Regards,
MarkThe APEX URL syntax is detailed here
http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/concept.htm#BCEDJBEH
How to get it from PDF is another matter...
I'm working on an app that downloads PDFs with a Large amount of data as a blob, takes that blob and changes it to XML, then goes through the xml to validate each section of data and then add it into the schema that my apex app is referencing....
I didn't write the original code but I do know that it isn't a quick thing to implement and includes using some uploading some java jar files to your schema and writing some custom java code.
Someone else may be able to help with grabbing PDF data into the URL for the amounts of data you want to pass to apex.
Gus..
REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!
Edited by: Gussay on Sep 21, 2009 5:52 PM -
How to get Position from EmployeeInfo in DIAPI
I am using DIAPI(JCO) for SAP B1. According to one or my reuirement i am in need of Position from the EmployeesInfo. But there seems no option or method for getting position from that. Can anyone guide me how to get that from EmployeesInfo ? Any help is appreciated..
Looking at the DI API properties vs. DB fields mapping documentation in the SAP Business One developer area (https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c5f5dbcc-0a01-0010-5d82-f25f2bee715e)
it seems that this field is not exposed (yet).
I.e. you could only run a SQL statement to get this information.
Sorry,
Frank -
Accessing ADF context from a custom servlet
I have an ADF web application which has AMs,VOs & JSPXs. I also have another custom servlet which will implement 3rd party integration logic.
I need to :
- access the[u] currently live AM ,VO running in my web application from my custom servlet and use that data and send it to the 3rd party
how do i access the VO/AM/BCs ?
i tried the http://www.thoughtsabout.net/blog/archives/000033.html approach ,but it doesnt seem to work.Hi,
note that you can only access this information if the servlet is in the same session as the running application. The "bindings" object and the "data" object are rehistered in the session. So you should be able to pull the "bindings" attribute from the session and cast it to DCBindingContainer.
However, in your servlet you will not have any control over what currently is in the bindings container. So accessing the datacontrol, which is the ADF BC AM is the most you probably can do safely. Note that changes applied from your servlet to the AM are not automatically reflected in the application. For this you need to re-query the iterarors used.
Frank -
how to get photos from mac to iPhone 6? when i try it just comes up iCloud instead of my photos
Make sure Settings > iCloud > Photos > iCloud Photo Library (Beta) = "Off"
Then sync your iPhone using iTunes and make sure your sync settings for photos are set correctly in iTunes. -
I got a new computer and don't know how to get music from ipod touch to itunes library
I recently got a new computer and don't know how to get music from my ipod touch to show on my itunes library.
You need to transfer the iTunes folder from the old computer to the new one.
iTunes: How to move your music to a new computer (Mac or Windows):
http://support.apple.com/kb/HT4527 -
I have a new MacBook Air and don't know how to get info from my USB stick and get info from my SD card. Can anyone help, please?
Plug the stick and/or card into the appropriate slots on the side of your Air. Do you see icons for the devices appear on the desktop? Click into them to see what files are there.
Matt -
How to get client IP in custom UCM Service
how to get client IP in custom UCM Service ?
have you tried
binder.getLocal("REMOTE_ADDR");
Let us know how you get on
Tim -
How to get data from a USB-UIRT device using Labview?
How to get data from a USB-UIRT device using Labview?
I'm trying to get data from a USB-UIRT device, is it posible with Labview?
I really appreciate your help,
thanksYou may want to contact the developer of the device for the API and DLL.
http://65.36.202.170/phpBB2/viewforum.php?f=3 -
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. -
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 FILENAME from FILE PATH
does anyone know how to get filename from a file path for example
FILE PATH: C:\Project\uploadbean\web\uploads\Button.txt
returns
FILENAME: Button.txt@BalusC
ust for a reference cause i'm new in JSP This has nothing to do with JSP, but with basic knowledge of an essential API. I have given you the link to the File API. Are you saying that you refused to read the API documentation, which clearly explains you how to use the File and shows which methods are all available to you undereach the straightforward getName() method, and expecting that the others may chew the answers for you? Loser.
Maybe you are looking for
-
How do i transfer music files from an sd card to a late 2008 model Macbook Pro?
The android phone I have is really messed up and I can't plug it in with a USB cable to transfer the music files so is there anyway I can transfer them with just the sd card? I know on the newer models there's a slot for the sd card adapter but it's
-
My Macbook Pro cannot sustain Safari for more than 5 minutes. Once I hit return the "working" icon just keeps going round and round. The only way to access the internet or my email is to totally shut down and then restart. Is there something I can ch
-
Booting from alternate disk in Sol 10 x86 1/06
Hey all-- I'm trying to set up a mirrored root filesystem on an x86 box with two IDE disks. It's running solaris 10 1/06. I've done this plenty of times on sparc boxes, but only once on an x86 box and after the metaroot, I had to edit bootenv.rc to p
-
Iphone many issues.. Over priced faulty crap? I think so
i got a new iphone for the firet time a month ago . and the power button got stuck .today it just didnt work at all i plugged it in expecting it to show its charging and notning! keep in mind its in perfect condition other than the faulty button and
-
0CRM_COMPLAINTS_I - Tables CRM
Hi, do anybody knows the tables for extractor 0CRM_COMPLAINTS_I ??? Are those informations stored in tables CRMD_ORDERADM_H and/or CRMD_ORDERADM_I ?? Thanks, Frank