How to return arraylist from servlet to midlet
hi everybody !
Can anybody help me in solving this problem.
I am working on an application in which I am using Midlet to servlet
communication.
In this I am sending username and password from Midlet to servlet .
At server side servlet check the authentication and send the corresponding
contactlist of user from database to the MIDLet.
On Midlet this list should appear list-wise.
please tell me that how can I achieve this....
Thanks in Advanced....
bhagwat
Hi,
Can u say how to lock folder without using any tools??
If i click on folder,it should ask for password.if the entered value is valid,the folder should open....
Can u provide code for this????
Is there any need to interact with operating system???
Please reply me soon..
Thanks in advance...
Vinoda
Similar Messages
-
How to send value from servlet to midlet?
I need to display value in textbox in emulator.
If i am creating textbox in servlet it wont display textbox
but it displays content available in out.println (html tags).
ThanksI�m king of Java, i have fixed it.
//Nisse -
How to return Collection from from entity bean to servlet?
hi
is it possible to return Collection from entity bean (Which is returns form CMR field ) to servlet ?
thanksSERVLET
public class test extends HttpServlet {
@EJB
private LocalBean lookupBean;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
for(Item i : lookupBean.getMyCollection() )
out.println(i.getItemName());
out.close();
}BEAN INTERFACE
public interface BeanLocal {
Collection<Item> getMyCollection();
}BEAN IMPLEMENTATION
@Stateless()
public class Bean implements BeanLocal {
@PersistenceContext()
private EntityManager em;
public Collection<Item> getMyCollection() {
return em.createQuery("SELECT i from ITEM i").getResultList();
} and if you create an instance of your servlet you'll have to reinitialize LocalBean
@EJB(name="myejbref", beanInterface=BeanLocal.class)
private BeanLocal lookupBean;
private BeanLocal getLookupBean() {
if(lookupBean == null) {
try {
InitialContext ic = new InitialContext();
lookupBean = (BeanLocal) ic.lookup("java:comp/env/myejbref");
catch(Exception e){
System.out.println(e.getMessage());
return lookupBean;
} -
How to send mail from servlets
m having troubles sending mail from servlets...
how do you use the SimpleMailUser object needed in the session?
a sample code on this would be of great help, thanks!<html>
<body bgcolor="white">
<font size=5 color="black">
<%@ page import="javax.servlet.http.HttpUtils" %>
<%@ page import="java.util.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.io.*" %>
<%@ page import= "sun.net.smtp.SmtpClient" %>
<%
String from,to,subject,msgbody,serverName;
try
from = request.getParameterValues("from")[0];
to = request.getParameterValues("to")[0];
subject = request.getParameterValues("subject")[0];
msgbody = request.getParameterValues("msgbody")[0];
serverName = request.getParameterValues("server")[0];
catch (Exception e) // Generally Speaking, an Error getting one of these
// Values means that it wasnt passed in; inform the user
out.println("You must call this JSP from this ");
out.println("<A href=\"FormMail.htm\"> form</A>.<BR>");
out.flush();return;
%>
Hold On A Moment while I try to Send Your Mail... <BR>
<%
out.flush();
// Here are the real guts of the mail sending
try
sun.net.smtp.SmtpClient sm = new sun.net.smtp.SmtpClient(serverName);
sm.from(from);
sm.to(to);
PrintStream msg = sm.startMessage();
msg.println("To: "); // Note dont use + for Performance
msg.println(to);
msg.println("Subject: ");
msg.println(subject);
msg.println();
msg.println(msgbody);
msg.println("==============");
msg.print("This mail brought to you by JSP MAIL..from a user at IP ");
msg.println(request.getRemoteHost());
sm.closeServer();
out.println("Your Mail Has Been Sent!");
catch (Exception e)
out.println("The mail couldn't be sent, probably because the mailhost wasnt set correctly.<BR> ");
out.println("The error message I am getting is: ");
out.println(e.getMessage());
%>
<BR>
<BR>
Click here to send another! -
How to show colors from servlet
Greetings
Please give me a example of how to show color baground and how to show buttons and list objects from servlets.
Thanks in advanceHere is the code sample:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletSample extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("</head>");
//set background color
pw.println("<body bgcolor="#99cccc">");
//list object?
ServletContext context = getServletContext();
pw.println(context.getRealPath("/."));
//create a submit button
pw.println("<button type=\"submit\">A Submit Button</button>");
pw.println("</body>");
pw.println("</html>");
}I recommand to take a tutorial or a book on Servlet -
How to return rows from tmp table created inside function??
Hi,
I'm trying to return rows from a cursor or table (created within
the function). How do I specify the return type?Hi,
Here is the code that examples to create a function that can
return data from table.This is achieved using REFCURSOR concept.
Hope this helps you.I'm giving all stuff in single PL/SQL
block.You can break it and create a package and declare
refcursor type and function in that as well.
DECLARE
-- Declare generic cursor type
TYPE gencur_type IS REF CURSOR ;
-- Declare generic cursor varaible
gencur gencur_type;
-- Declare record type
TYPE rec_type IS RECORD(descr emp.ename%type) ;
-- Declare record type variable
rec rec_type;
--This how you declare a local function that returns gencrtype
data set
--This function is called in main block
FUNCTION call_refcur return gencur_type
AS
rr gencur_type;
BEGIN
OPEN rr FOR SELECT descr FROM emp;
RETURN rr;
END;-- end of local function
-- Main block begins here
BEGIN
-- Call the local function so that gencur will have
-- the data set returned by select statement
gencur:= call_refcur;
-- Open a loop to test the stuff
LOOP
FETCH gencur INTO rec;
EXIT WHEN gencur%NOTFOUND;
null;
dbms_output.put_line(rec.ename);
END LOOP;
END;
Regards,
Sridhar -
Oracle forms 9i - How to return back from a block?
Some one please help me
In a trigger, I have a code says go_block. How to return from the block and back to the trigger to continue executing the codes below the go_block statement? Please see example below, I want to come back from block CHECK_STUFF and continue execute the statements
:Name.option := '1';
if :name.option = '1' then
Example:
Block: Name
Item: yes_no - Key-next-item trigger
declare
begin
go_block('check_stuff');
go_item('answer');
:Name.option := '1';
if :name.option = '1' then
Thanks - PattyThe code behind the GO_BLOCK is executed immediately after the GO_BLOCK, it doesn't stop at that point. So you have to split your code, like
declare
begin
go_block('check_stuff');Then, create a procedure like
PROCEDURE PR_RETURN_FROM_BLOCK IS
BEGIN
go_item('answer');
:Name.option := '1';
if :name.option = '1' then
END;Then, when returning from the block (in whatever trigger you use), just call that procedure. -
How to return error from subscription function of an event
I am creating a subscription function for an oracle shipped event, oracle.apps.eng.cm.changeObject.submit. The event fires fine, i can do my custom validations in this function. In case the validations fail, I need to return an error message.
As per the guides and metalink documents, the way to do this is by returning 'ERROR' . But even though I return an ERROR, it does not error out. Whether I return SUCCESS or ERROR , the behaviour is the same.
While creating the subscription function, for On Error , I selected, "Stop And Rollback ".
Is it possible to return errors from the subscription functions.
thanks
SatyaYou shouldn't be passing ResultSet objects across the EJB layer.
Instead you should be passing data back and forth.
All of the data access code should be in one place in one class.
That class should open the connection, run the query, process/store the results of the query and then close the connection.
In this case you probably want to return a list of something to your jsp.
So your EJB call should be more like
public List<resultBean> check(String id){
ResultSet rs = Statement.("select * from table1 where id=123");
List resultList = new ArrayList();
while (rs.next()){
Bean myBean = new Bean();
myBean.setProperty1(rs.getString("field1"));
myBean.setProperty2(rs.getString("field2"));
resultList.add(myBean);
return resultList;
} -
How to return cursor from procedure to jdbc
plz help me through example of code as wl as procedure where.... return cursor from procedure to jdbc
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE procedure anil3 @count INT OUT,@opcode INT OUT,@total_tiff INT OUT
as
declare @query2 varchar(300),@tiff_count int,@query1 varchar(300)
set @query1='declare move_cursor cursor forward_only static for
select count(opcode),opcode from TABLE1 group by opcode
open move_cursor'
exec(@query1)
fetch next from move_cursor into @count,@opcode
set @opcode="'"+@opcode+"'"
set @total_tiff=0
while (@@fetch_status=0)
begin
set @query2='declare move_cursor2 cursor static for '+
' select count(tiff) from TABLE2 where opcode='+@opcode+
' open move_cursor2 '
exec(@query2)
fetch next from move_cursor2 into @tiff_count
while (@@fetch_status=0)
begin
set @total_tiff=@total_tiff+@tiff_count
fetch next from move_cursor2 into @tiff_count
end
close move_cursor2
deallocate move_cursor2
print @total_tiff
print @count
print @opcode
fetch next from move_cursor into @count,@opcode
end
close move_cursor
deallocate move_cursor
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO******************************************************************************
above this is sql server 2000 PL/SQL and i hv to get the value
print @total_tiff
print @count
print @opcode
through JDBC
plz help me out how to return Cursor to JDBC and HOW toPRINT THESE THREE VALUE @total_tiff, @count, @opcode through JDBC
get this values through JDBC -
How to return fault from Async BPEL
Hi,
I have ESB that has input,output and fault, This ESB calls Async BPEL that takes only input. Now i want to return fault from BPEL to ESB. How do i do it?
Please help.Hi,
My use case is i am implementing AIA. So my enterprise layer is ESB and my ABCS provider is BPEL. As provider takes lot of time to complete the instance, to avoid timeout issue i just created Async BPEL with two ports one for input another for fault. I am able to send back my fault back to this call back port. But how i can receive the fault to the same ESB which called the BPEL?
I am not able to implement it. I can not go for any workaround like creating one more BPEL and then make it as sync, put pick activity and receive the fault then send back to ESB.
Thats the reason i am very specific. If you find some solution please let me know. -
How to return fault from Async BPEL to ESB
Hi,
I have ESB that has input,output and fault, This ESB calls Async BPEL that takes only input. Now i want to return fault from BPEL to ESB. How do i do it?
Please help.Hi,
My use case is i am implementing AIA. So my enterprise layer is ESB and my ABCS provider is BPEL. As provider takes lot of time to complete the instance, to avoid timeout issue i just created Async BPEL with two ports one for input another for fault. I am able to send back my fault back to this call back port. But how i can receive the fault to the same ESB which called the BPEL?
I am not able to implement it. I can not go for any workaround like creating one more BPEL and then make it as sync, put pick activity and receive the fault then send back to ESB.
Thats the reason i am very specific. If you find some solution please let me know. -
How to call JSp from Servlet??
Hello,
I want to call JSP page from servlet.I am using Visual Age For java 3.4. What is wrong in my code??
if (userExists) {
f.setErrors("userName","Duplicate User: Try a different username");
getServletConfig().getServletContext().
getRequestDispatcher("/jsp/forms/retry.jsp").
forward(request, response);
I am not able to get the o/p. Pls help.I can't see anything obvious, but did you take any steps towards doing output before this code (like openning an output stream)?
Not clear what f.setErrors does - presumably stuffs the error message in an attribute of the request. -
How to return data from Ejb as collection to Front End application.
Hi,
I am creating a J2ee application. Here i am accessing BAPIs using stateless session bean through JCO connection. Now the BAPI is returning a return Table and return Structure to the EJB.
I have coded the following code in one of the Ejb Method as follows:
JCO.Table returnTable = null;
JCO.Structure returnStructure = null;
JCO.ParameterList paramList = siteBAPI.getExportParameterList();
JCO.ParameterList paramList2 = siteBAPI.getTableParameterList();
returnTable = paramList2.getTable("SITE_SUBSITE_INSTL");
returnStructure = paramList.getStructure("BAPIRET2");
Now i want to sent this data( returnTable & returnStructure) to front end application where front end developer accessing this returned data using Jsp.
My scenario is that , first i want to convert this returnTable & returnStructure in a single collection and then sent this collection to Front end.
My aim is that , the front end the application should not receive the Data, using JCO.table Variable but as a single Collection.
I am using NWDI-2004s sps10.
i need urgent help on this issue and i would really appreciate if somebody can put the answer with some sample code on how to return the data as Collection.if you want to return a result, then you probably shouldn't be using a message bean. message beans for for asynchronous tasks. session beans for for synchronous tasks. thus it would make much more sense to have your jsp call the session bean directly.
-
How to execute package from Servlet
Hi all...
I have set of class files in a package called iDen_parser.
My main class name is jump_calc..
String[] cmd={"cmd.exe" , "/c" ,"java iden_parser.jump_calc","d:/test.log","d:/test.txt"};
Runtime runtime = Runtime.getRuntime();
process = runtime.exec(cmd);
I am not getting any output...
I have placed the folder Iden_parser in current working directory itself.
While I when I am trying out simple program HelloWorldApp, it's working out fine.
String[] cmd={"cmd.exe" , "/c" ,"java HelloWorldApp};
Runtime runtime = Runtime.getRuntime();
process = runtime.exec(cmd);
So anyone ,pls help me out in executing the pakage from servlets
Thnk
VIjayHi...
I am placing my code here
String path1 ="cmd /c dir /d";
String[] cmd={"cmd.exe" , "/c" ,"java
java HelloWorldApp"};
String[] path ={"cmd.exe",null, "
java iden_parser.jump_calc", "d:/test.log","
d:/mygod.txt"};
Replace....
String[] path ={"java iden_parser.jump_calc", "d:/test.log","
d:/mygod.txt"};
Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
process = runtime.exec(path);
Replace....
process = runtime.exec(path, null, "the dir from where u call the stand alone program on command prompt");
outHTML.println("PAth" +path);
BufferedReader in =
new BufferedReader(new
er(new InputStreamReader(process.getInputStream()));
// Read and print the output
String line = null;
outHTML.println("Something had happen");
if((line = in.readLine()) == null)
outHTML.println("Empty");
while ((line = in.readLine()) != null) {
outHTML.println(line);
catch (Exception e) {
outHTML.println("Did not execute the command
command " );
//out.println("Problem with finger: " +
// ServletUtils.getStackTraceAsString(e)); -
How to display data in canvas which is fetched from servlet to midlet.
I am able to display data from database using servlet.
I am using MySQL as database.
But i want to display it more nicely using canvas. Right now i just print all the data's , it doent look professional.
I want to know how to show those data's nicely. How to use canvas? where i can use canvas? Is there any other way to display data/records so that it looks more professional.
Need help as soon as possible.
Thanks in advance.hey listen i created midlet and servlet. I can see the record which is on my database but as i have just printed using servlet on the mobile screen. Now i want to display those records nore nicely that is . say for example
i am showing personal profile of a user.
I am just displaying like ---"Name:" Abc,
Age: 27 etc
now i wnat to bold "Name" , "Age" stuff like that.
I want to use color etc but i dont know how to do that. How can i my records look good?
I have stored all the record in resultset and have passed it to midlet not i want display it more nicely. How to do that?
Maybe you are looking for
-
I have a photo slide show PDF file in an email. How to I transfer the photos in my camera roll on my iPad?
-
Notes do not sync from iCloud to iPhone 4s AND Notes disappear from iPhone
My notes are not syncing from iCloud to my iPhone 4s. I turned Notes 'off' on my iPhone (Settings>iCloud>Notes), then back on. Now all of my notes on my iPhone have DISAPPEARED. Restarted my 4s - no change. I created a test Note on iCloud.com and it
-
Image looks grainy in Photoshop CC but not in CS5
All of my images look grainy int he dark areas in CC, but not in CS5. Is there a display setting that I'm missing? Side note, the saved images look fine. They only look bad in the CC UI. Screen shot of CC Screen shot of CS5 Photshop CC and CS5 64-
-
Report Painter, GL Set does not have description
Hi Expert, I want to create Columnar Financial Statement (Profit and Loss Account, and Balance Sheet). My problem is that my GL under the lead column does not have any GL description shown. I tried some of the settings for lead column under formattin
-
Table of Contents - Character style differentiation
After reading another post from the end of July regarding the same subject, I fear that there may be no solution, but I just want to confirm and ask for clarification. It the table of contents of my PhD thesis there are a few titles that have individ