Why passing string from applet to jsp doesn't work?
Hi,all:
I have a application requires applet to get client side info, then pass this "info"--string to the JSP.
Applet code:
try{
URL url = new URL(getCodeBase(),"test.jsp?
java.version=1.2.2&java.vendor=Sun);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", "application/octet-stream");
conn.connect();
} catch (Exception e) {
System.out.println("The error is at URL:"+e.getMessage());
My jsp code is:
<%
String java_version=request.getParameter("java.version");
String java_vendor=request.getParameter("java.vendor");
%>
However, it doesn't work. Could anybody help me figure out?
Thanks in advance.
Paul
Request Jsp with
test.jsp?URLEncoder.encode("java.version")=URLEncoder.encode("java.version.value")&URLEncoder.encode("java.vendor")=
URLEncoder.encode("java.vendor.value")
Similar Messages
-
Passing data from Applet to JSP and back
What is the best way for me to communicate between an Applet and a jsp page? I want to be able to call Applet methods from the JSP and be able to send data to the JSP from the Applet. Thanks.
Can't do this
JSP lives on the server. When it's done, the code is sent to the client
So, in terms of lifespan...
JSP -> Internet -> Client -> Applet
JSP is dead before applet starts -
Pass data from servlet to jsp using sendRedirect
Hi,
I am passing data from servlet to jsp using forward method of request dispatcher but as it doesn't change the url it is creating problems. When ever user refreshes the screen(browser refresh) it's re-loading both servlet and jsp, which i don't want to happen. I want only the jsp to be reloaded.
Can I pass data from servlet to jsp using sendRedirect in this case. I also want to pass some values from servlet to jsp but without using query string. I want to set some attributes and send to jsp just like we do for forward method of request dispatcher.
Is there any way i can send data using attributes(without using query string) using sendRedirect? Please let me knowsendRedirect is meant as a true redirect. meaning
you can use it to redirect to urls not in your
context....with forward you couldn't pass information
to jsps/servlets outside your own context.Actually, you can:
getServletContext().getContext("/other").getRequestDispatcher("/path/to/servlet").forward(request, response)I think the issue here is that the OP would like to have RequestDispatcher.forward() also update the address in the client's browser. That's not possible, AFAIK. By the time the request is forwarded, the browser has already determined the URL of the servlet, and the only I know of way to have the browser change the URL to the forwarded Servlet/JSP is to send a Location: header (i.e. sendRedirect()). Remember that server-side dispatching is transparent to the client. Maybe there's some tricky stuff you can do with JavaScript to change the address in the address bar without reloading the page?
Brian -
How to Pass values from XML to JSP??? Urgent Please Help me
Hi guys,
I am new to XML, I want to pass values from XML to JSP. I have a xml file with attributes, I should send this values to a JSP file. How is it??? Please Help guys.... its very urgent. Please send me how to do it with an example or atleast any urls related that....
Looking for ur favourable reply.
Thanks in advance,
Sridharin a servlet :
parse your xml file (see how at the end of the post) and
put the values you want in the request attributes
request.setAttribute("value1", value1);
...redirect to the jsp
in the JSP:
get the wanted attributes:
String value1=(String)request.getAttribute("value1");To learn how to parse a xml file, pay a look at this page, it explains how to read the XML document to build an object representation, and then how to navigate through this object to get the data
http://labe.felk.cvut.cz/~xfaigl/mep/xml/java-xml.htm -
Parsing in Weblogic/jsp doesn't work; application-mode (command-line) works
Hello-
Parsing my XML file in Weblogic/jsp doesn't work, whereas it works
in application-mode... (albeit on two different machines)
Here are the parameters:
server1:
weblogic 6.0
win2k server
jre1.3
my personal machine:
***no weblogic***
win2k server
jre1.3
When I run my code as an application (command-line style) on my machine,
parsing in my xml file works fine, and I can do a root.toString() and it
dumps out the entire xml file, as desired.
However, running my code inside weblogic (on server1) in JSP, parsing in
my file and doing a root.toString() results in the following: [dmui: null]
(where dmui is my root)
(even though i'm running it on two different machines, i'm positive its the
same code (the servers share a mapped drive)...
So, I think its probably because I'm using a different parser, as
specified by weblogic? There are no exceptions being thrown. Here's my
(abbreviated) code, which is called either command line style or in a JSP:
// Imports
import org.w3c.dom.*;
import org.w3c.dom.Document;
import javax.xml.parsers.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
mDocument = docBuilder.parse (inFile);
myRoot.toString()
-END
Doing a System.getProperty("javax.xml.parsers.DocumentBuilderFactory")
results in:
server1 (weblogic/jsp):
"weblogic.apache.xerces.jaxp.DocumentBuilderFactoryImpl"
my machine (application-mode):
null
Does anyone have any ideas about how to get this work? Do I try to set it
up so that they both use the same parser? Do I change the Weblogic parser?
If so, to what? And how?
Am I even close?
Any help would be appreciated..
Thanks, Clint
"[email protected]" <[email protected]> wrote in message
news:[email protected]...
No problem, glad you got it worked out :)
~Ryan U.
Jennifer wrote in message <[email protected]>...
I completely missed setting the property(:-o), foolish mistake. That wasit. Thanks.
"j.upton" <[email protected]> wrote:
Jennifer,
Personally I would get rid of import com.sun.xml.parser.* and use xerces
which comes with WLS 6.0 now, unless like I said earlier you have a need
to
use the sun parser :) Try something like this with your code --I've put
things to watch for as comments in the code.
import javax.xml.parsers.*;
import org.xml.sax.SAXException;
import org.w3c.dom.*;
import java.io.FileInputStream;
public class BasicDOM {
public BasicDOM (String xmlFile) {
try{
FileInputStream inStream;
Document document;
/*You must specify a parser for jaxp. You can in a simple view
think
of this as being analogous to a driver used by JDBC or JNDI. If you are
using this in the context of a servlet or JSP and have set an XML
registry
with the console this happens automatically. You can also invoke it in
the
context of an application on the command line using the -D switch. */
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
>>>
"weblogic.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
// create a document factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// specify validating or non-validating parser
dbf.setValidating(true);
// obtain a factory
DocumentBuilder db = dbf.newDocumentBuilder();
// create a document from the factory
inStream = new FileInputStream(xmlFile);
document = db.parse(inStream);
}//try
catch (Exception e)
System.out.println("Unexpected exception reading document!"
+e);
System.exit (0);
}//catch
}//BasicDom
// Main Method
public static void main (String[] args) {
if (args.length < 1)
System.exit(1); file://or you can be more verbose
new BasicDOM(args[0]);
}//class
=============================================
That will give you a basic DOM you can manipulate and parse it fromthere.
BTW this code
compiled and ran on WLS 6.0 under Windows 2000.
Let me know if this helped or you still are having trouble.
~Ryan U.
"Jennifer" <[email protected]> wrote in message
news:[email protected]...
Actually I included com.sun.xml.parser.* as one last febble attempt toget
it working.
And as for source code, I included the code. If I just put that oneline
of code
in, including the imports, it fails giving me an error listed above inthe
subject
line. Here is the code again:
package examples.xml.http;
import javax.xml.parsers.*;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.w3c.dom.*;
import java.util.*;
import java.net.*;
import org.xml.sax.*;
import java.io.*;
public class BasicDOM {
static Document document;
public BasicDOM (String xmlFile) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
} catch (FactoryConfigurationError e){
System.err.println(e.getException());
e.printStackTrace();
// Main Method
public static void main (String[] args) {
BasicDOM basicDOM = new BasicDOM (args[0]);Hi, Rob
Does it work in WL9.2?
It seems I do it exactly as the explained at http://edocs.bea.com/wls/docs81/programming/classloading.html - and it fails :o(.
I try to run my app.ear with WL9.2 There are 2 components in it: webapp and mdb. The webapp/WEB-INF contains weblogic.xml:
<weblogic-web-app>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
Mdb is expected to run in the same mode, i.e. to prefer the webapp/WEB-INF/*.jar over the parent Weblogic classloader. To do so I add the weblogic-application.xml to the app.ear!/META-INF:
<weblogic-application>
<classloader-structure>
<module-ref>
<!-- reminder: this webapp contains
prefer-web-inf-classes -->
<module-uri>webapp</module-uri>
</module-ref>
<classloader-structure>
<module-ref>
<module-uri>mdb.jar</module-uri>
</module-ref>
</classloader-structure>
</classloader-structure>
</weblogic-application>
Now, when classloader-structure specified, both webabb and mdb prefer the weblogic root loader as if prefer-web-inf-classes not defined at all. -
My Applet Jar file doesn't work !!
hello ,
I have written this java applet :
import java.awt.*;
import javax.swing.*;
import java.applet.Applet;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
public class test4 extends Applet implements ActionListener{
private static final long serialVersionUID = 1L;
private JButton B1 =new JButton("Forward ");
private JButton B2 =new JButton("Backward");
private JButton B3 =new JButton("Left");
private JButton B4 =new JButton("Right");
private JPanel P1 = new JPanel();
private JPanel P2 = new JPanel();
private JPanel P3 = new JPanel();
private JPanel P4 = new JPanel();
private JPanel P5 = new JPanel();
private JPanel P6 = new JPanel();
private JLabel L3 = new JLabel(" ");
private JLabel L4 = new JLabel(" ");
private JLabel L5 = new JLabel(" ");
private JLabel L6 = new JLabel(" ");
private JLabel L7 = new JLabel(" ");
JSplitPane sppSplitPane0 = new JSplitPane( );
public test4()
JFrame.setDefaultLookAndFeelDecorated(true);
sppSplitPane0.setDividerLocation( 250 );
P3.add(L4);
P3.add(B1);
P3.add(L5);
P5.add(B3);
P5.add(L3);
P5.add(B4);
P4.add(L6);
P4.add(B2);
P4.add(L7);
P1.setLayout(new BorderLayout());
P1.add("North",P3);
P1.add("Center",P5);
P1.add("South",P4);
P2.setLayout(new BorderLayout());
P2.add("North" , P1);
B1.addActionListener(this);
B2.addActionListener(this);
B3.addActionListener(this);
B4.addActionListener(this);
sppSplitPane0.setLeftComponent(P2);
sppSplitPane0.setRightComponent(P6);
public void actionPerformed(ActionEvent e) {
try {
if (e.getSource() == B4) {
URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?R");
System.out.println("URL = " + myNewURL);
getAppletContext().showDocument(myNewURL,"blank");
else
if (e.getSource() == B3) {
URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?L");
System.out.println("URL = " + myNewURL);
getAppletContext().showDocument(myNewURL,"blank");
else
if (e.getSource() == B2) {
URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?B");
System.out.println("URL = " + myNewURL);
getAppletContext().showDocument(myNewURL,"blank");
else {
URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?F");
System.out.println("URL = " + myNewURL);
getAppletContext().showDocument(myNewURL,"blank");
} catch (Exception err) {
System.err.println("Error!\n" + err);
showStatus("Error, look in Java Console for details!");
public static void main(String[] args) {
test t=new test();
JFrame frame =new JFrame();
frame.add(t.sppSplitPane0);
frame.setSize(1100,700);
frame.setVisible(true);
i made a jar file :
i created a file and named it MANIFEST.MF .i wrote inside it :
Main-Class: test
Then i placed it in a folder with the test.class .I created jar file using command line.
I entered the test.class path and then wrote this command :
jar cvfm myjar.jar MANIFEST.MF *.class
Then the jar file "myjar.jar" is created .
it's executed but this function "public void actionPerformed(ActionEvent e) " won't wrok.
i keep pressing the buttons but nothing is happening !!
please help me .
Edited by: Amera on Dec 27, 2009 2:51 PMWelcome to the Sun forums.
Subject: My Applet Jar file doesn't work !! .
1) Note that one '!' denotes exclamation, whereas 2 or more often denotes a dweeb.
2) Since you are on your first post, I will point out that applets are an advanced topic, and should not be attempted by newbies.
3) "doesn't work" is very vague. It is likely to produce a reply like "maybe the applet is lazy - try flogging it".
Amera wrote:
..I have written this java applet :When posting code, code snippets, HTML/XML or input/output, please use the code tags. The code tags help retain the formatting and indentation of the sample. To use the code tags, select the sample and click the CODE button.
Also note that the most preferred form of code is an SSCCE *(<- link).* In an SSCCE, your would remove all but one button (if the actionPerformed fails with 6 or 7 buttons, trim it down to fail with just one or two.
i made a jar file :So does the applet work before you make the Jar file? Your post so far suggests the Jar file is the problem.
i created a file and named it MANIFEST.MF .i wrote inside it :
Main-Class: test
Then i placed it in a folder with the test.class .I created jar file using command line.
I entered the test.class path and then wrote this command :
jar cvfm myjar.jar MANIFEST.MF *.class
Then the jar file "myjar.jar" is created .
it's executed but this function "public void actionPerformed(ActionEvent e) " won't wrok.
i keep pressing the buttons but nothing is happening !!So you get 'no output in the console & no effect in the applet'?
What is the URL where I can see your applet failing?
As an aside, since Sun does not guarantee that applet clients will act on the showDocument command, even if it does not work, it would not be a 'bug'.
Edited by: AndrewThompson64 on Dec 28, 2009 11:18 AM -
I am trying to download a file from Safari. It doesn't work.
I am trying to download a file from Safari. It doesn't work. It always comes up with a notification saying, 'Safari could not download this file'. Why does it do that? More importantly, what should I do? how do I download it?
Thanks to the users who reply to this. It will help me a lot.What type of file is it?
If safari can't natively open the file, or there is no App installed thatr can, it won't download. -
How can I upload a video from my PC through I tunes to camera roll on my iPhone? Is there an app or format of specific video supported? Sync from photos include video doesn't work for me.
download the new you tube apps in i tunes, in os6 just pick a video in the photos apps and select share, the old you tube app icon will appear
-
why copy option from recent call numbers is not working on ios7 [recent call logs in phone]?
Here is a copy of my expressions and a copy of my data. The expressions match up going from left to right
Code.CalcPTD2(Lookupset(FORMAT(Fields!REALDATE.Value,"Long Date"),FORMAT(Fields!CallbackDate.Value,"Long Date"),Fields!DailyHours.Value,"DataSet4"))
sum(Code.CalcPTD2(Lookupset(FORMAT(Fields!REALDATE.Value,"Long Date"),FORMAT(Fields!CallbackDate.Value,"Long Date"),Fields!DailyHours.Value,"DataSet4")))
count(Code.CalcPTD2(Lookupset(FORMAT(Fields!REALDATE.Value,"Long Date"),FORMAT(Fields!CallbackDate.Value,"Long Date"),Fields!DailyHours.Value,"DataSet4")))
PUBLIC SHARED FUNCTION CalcPTD2(LookupArray AS OBJECT) AS INTEGER
DIM i,Total AS INTEGER
Total = 0
FOR i = 0 to UBOUND(LookupArray)
Total = Total + CINT(LookupArray(i))
NEXT i
NumberTimes = NumberTimes +1
RETURN Total
END FUNCTION -
Photostream from PC to Ipad doesn't work
Hello, I have installed ICloud on my Ipad en on my Windows 8 laptop. Photostream from Ipad to laptop is ok but from laptop to Ipad doesn't work.
I have contacted Apple support but the couldn't figure it out, I tried everything: disable firewall in router and laptop, also disabeld Defender, installed a new
ICloud, installed new OS on the Ipad, all the photo's are in the upload folder, the battery of the Ipad is 100% filled, the Wifi works ok. etc.etc. I suppose that
there must be a wrong configuration somewhere, perhaps the Wifi must be in BootP on the Ipad or I have to enable a kind of service in the laptop or perhaps
it is just a stupidity from me? Who has an idea?
Thnx RJZLooks like they changed how this works in iCloud Control Panel 2.0
"On a PC with iCloud Control Panel 2.0 or later, open a Windows Explorer window. Select Photo Stream under Favorites. Open My Photo Stream. Click the "Add photos" button. Select photos to import to My Photo Stream, and then click Open."
And here is the source:
iCloud: Photo Stream FAQ - Support - Apple -
Translation from CS5 to Cloud doesn't work correct, navi and linked images are broken.
Translation from CS5 to Cloud doesn't work correct, <navi> and linked images are broken.
The data of CS5 was created at another PC. I installed Cloud version into two different PC. One has had the site data since dreamweaver CS5 and it works correct in Cloud version. Another PC got the site data from remote server and it doesn't work correct. <navi> and linked image are broken.Another PC got the site data from remote server and it doesn't work correct. <navi> and linked image are broken.
This implies your site is not properly defined in DW. Go to Site > Manage Sites.
Or simply go to your other installation of DW and export the site definition file from Manage Sites.
Save it to a flash stick or other removable drive. Then import the STE file into your 2nd installation of DW.
Nancy O. -
I installed Oracle Portal Early Adoptor edition to Windows 2000. I noticed that the Oracle HTTP server has Apache/Jserv. The servlet sample works, however the JSP doesn't work. There aren't any documentation about JSP. Do I have to install a 3rd party JSP web server such as JRUN to run JSP? Thanks.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sir Gawin:
I installed Oracle Portal Early Adoptor edition to Windows 2000. I noticed that the Oracle HTTP server has Apache/Jserv. The servlet sample works, however the JSP doesn't work. There aren't any documentation about JSP. Do I have to install a 3rd party JSP web server such as JRUN to run JSP? Thanks.<HR></BLOCKQUOTE>
I would also be interested in this answer.I had test site running on a win2000 server with Apache/Jserv until I installed WebDB. Now I can connect via a web browser to the default WebDB site but the Apache HTTP sevices refuse to start up giving an error message 1069( or something like that). WebDB is configired to a different port( not 80)than Apache http
null -
Bought a new iPhone 6 and synced from iTunes but vibration doesn't work.
Bought a new iPhone 6 and synced from iTunes but vibration doesn't work. I did the reset option using side and home buttons but in vain. Please don't tell me to set up a new device coz its gonna be a hassle restoring apps, emails, contacs...etc.
Try to reset the phone by holding the sleep and home button for about 10sec, until the Apple logo comes back again. You will not lose any data by resetting, but it can cure some glitches.
If this does not help, setting it up as new device would be the next step:
How to erase your iOS device and then set it up as a new device or restore it from backups -
I have some apps on my ipad and I want to install more ,but it doesn't show the apps on the home and when I try to open them from the AppStore it doesn't work , what should I do?
Are you not seeing the icon of the app you just downloaded (it happens sometimes, and the quick fix is to reset your iPad)? Or are you running out of space on your iPad?
-
I have an iphone5 and the reply, forward and writing a message from the mail app doesn't work. I can check my mail but can't reply to it. What's going on?
Try a reset: hold down the home button along with the sleep/wake button until you see the apple, then let go. (No data loss)
Maybe you are looking for
-
Hi Experts, I'm trying to load data from a flat file into an Oracle table, but facing some issues. Concern - (1) I have a directory where there are ~20 similar files named like 'rb_1', 'rb_2', 'rb_3', etc... All these data should be loaded into a sin
-
Hi, I am developing a new form using 6i Forms. The requirement is to first have a Find form and then when we click on 'Find', it should open the main form. I have developed both the forms. But my question is, where do we explicitly define that it sho
-
Howdy all, My show is listed BUT I need to change some things in Feed Burner so they display properly. I need to change the name of the hosts, and the e-mail address. If anyone knows the answer please let me know. Thanks, Charlie
-
QuickTime "Lightbox" on the Web
Does anyone know what technique Apple and others use to create that Lightbox-like frame when playing QuickTime videos on the Web? It's the frame that, after clicking on the play video link, jumps out of the Web page and plays the video in front of th
-
Anyone have any idea how data usage is reported when viewing online... Don't quite understand how this works. I have unlimited plan but a little confused... Here is an example of what is reported What happened at 4am that generated 11MB of usage...C