How to include .js file in jsp file?
hi,
i have a jsp file with struts tag. right now i have all the javascript code as a separate function inside the jsp file itself. i want the javascript code to be present in a .js file and i want to refer that .js file from the jsp file with struts tags.
<html:text property="Phone" value="" size="3" maxlength="3"
onkeyup="return autoTab(this, 3, event);"></html:text>
the above is the html tag which will call the function "autoTab" of the .js file. please help.
thanks,
Jayanth.
You include javascript into a jsp in exactly the same way you do with html
<script src="myJavascriptFile.js"/>
It has nothing to do with the jsp per se, but rather the generated HTML page.
Similar Messages
-
Executing *.xml files as *.jsp files
Under other web containers this usually takes about 4 lines in a config xml file.
I am still hunting through the online doco
but I was wondering if anyone could point
me to the relevant section quicker ? ...
Basically what I am looking to do is to
tell the server to parse and execute *.xml
files as *.jsp files. It should be a simple
mapping somewhere in the config files.
Thankyou in advance,
Brian.Chuck,
That isn't quite what I want to achieve. What I have done
elsewhere is place the following servlet mapping in the Web
Container's web.xml file.
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.xml</url-pattern>
</servlet-mapping>
which then causes all *.xml files to be processed as *.jsp files.
Servlet name being the name of the servlet that processes the
JSP files for the web container. Is there an equivalent
thing under BEA ? Does BEA have a servlet which processes
JSP files or does it use something different ?
Cheers,
Brian.
"Chuck Nelson" <[email protected]> wrote:
>
Brian,
You should be able to update the web.xml for this purpose
e.g.
<servlet>
<servlet-name>myFoo</servlet-name>
<jsp-file>SnoopServlet.xml</jsp-file>
</servlet>
See the following URL for a more detailed description
http://edocs.bea.com/wls/docs61/webapp/components.html#100437
Chuck Nelson
DRE
BEA Technical Support -
Hi,
How do i include an external .js(JavaScript) file into a JSP file?My .js file is located in some package(lets say abc.jar). Below is my application structure:-
jsp
|
->MyJsp.jsp
lib
|
|
abc.jar
|
|
->com.abc.test
|
|
->Test.java
->abc.jsHow do i include "abc.js" file in "MyJsp.jsp" file?
Please help.
Thanks,
Kiran
Edited by: Adimulam on Jun 2, 2008 1:22 PMEven this is also not possible because, the code in that package is developed by DWR and i am just adding it to my lib folder and importing the respective classes. In the same manner i need to include the *.js* file in the JSP.It took me about 3 minutes reading through the [DWR Getting Started|http://getahead.org/dwr/getstarted] page to learn that you don't have to do any of that. Perhaps you should read that page?
-
How to include .css file into jsp file in portal application
Hi,
I have included a .css file in a .jsp file using following tag :
<link rel="<%=componentRequest.getWebResourcePath()%>/css/ts.css">.
I have kept .css file under /dist/css folder.
Preview of jsp file is fine but when I upload the jsp file and .css file to server, Look and feel of the screen is changing. When I paste the style code in jsp file, look and feel is fine.
Can some body suggest me that why the look and feel is changing when I put the style code in css file and include it in jsp.
Thanks in advance.
ManishHello
We're using <link rel="stylesheet" type="text/css" href="http://ourserver/eclib/css/ecstandard.css">
between <head> and </head>
It works.
Hope it helps.
Regards
Benoit -
How to use mxml in a jsp file?
I'm trying to use flex in a .jsp file. I followed the
suggestion that I use the Flex 2 Tag library as suggested by this
link:
http://labs.adobe.com/wiki/index.php/Flex_2_Tag_Library_for_JSP#Download_and_Installation
but I couldn't find it. I also downloaded LiveCycle Data Services
ES but couldn't find the flex-bootstrap.jar.
I have a simple example:
<!--<%@ taglib uri="FlexTagLib" prefix="mm" %>-->
Use the <mxml> tag to insert a Flex application in an
existing JSP page. The following example shows the <mxml> tag
with the source attribute to include an external MXML file:
<mm:mxml source="CustomerServiceChat.mxml"/>
Alternatively, you can use the <mxml> tag with inline
MXML source code, as the following example shows:
<mm:mxml>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns="*">
<mx:Text label="Hello World">
</mx:Application>
</mm:mxml>
I also added the following code in my web.xml:
<taglib>
<taglib-uri>FlexTagLib</taglib-uri>
<taglib-location>/WEB-INF/lib/flex-bootstrap.jar</taglib-location>
</taglib>
and obviously I get an error because I don't have the
flex-bootstrap.jar file. Please let me know how this can be
corrected. Thanks in advance!Adobe Newsbot hopes that the following resources helps you.
NewsBot is experimental and any feedback (reply to this post) on
its utility will be appreciated:
Adobe - Developer Center : Flex quick start guide for PHP
developers:
Apr 30, 2007 ... In this example, I changed the result data
type to XML with E4X support by setting .... In Flex you would
download a file using this code:
Link:
http://www.adobe.com/devnet/flex/articles/php_getstarted.html
2d. Tutorial - Flex 3 Getting Started - Adobe Learning
Resources:
See Calling XML Web Services over the Web Using the Web
Service References ... For information on integrating PHP and Flex
using AMF to encode the data,
Link:
http://learn.adobe.com/wiki/display/Flex/2d.+Tutorial
Mike Potter: Flex and PHP - A simple sample:
I have other example with PHP and MySql and give the same
error, and a example .... Flex Data Services... I choose None (???)
because I work with php and
Link:
http://blogs.adobe.com/mikepotter/2006/02/flex_and_php_a_1.html
Adobe - Developer Center : Transmitting data between Flex and
PHP:
Sep 4, 2007 ... Now that the user interface is set up and
ready to go you can add the HTTP services to go ask for the data
from the PHP code. In Flex you
Link:
http://www.adobe.com/devnet/flex/articles/flex_php_json.html
Integrating Adobe Flex and PHP:
Mar 1, 2006 ... The first step is to download Flex Builder
2.0 from the Adobe labs ... For example, you could use this same
PHP script to pass data to a
Link:
http://devzone.zend.com/article/11-Integrating-Adobe-Flex-and-PHP
Disclaimer: This response is generated automatically by the
Adobe NewsBot based on Adobe
Community
Engine. -
How to include commandline options in Batch File
Hi i have following code for batch file now i want to include one more optionas -savemndl
command is
loader.bat -savemndl (savedmndl file) (inputmndl file) (output Logfile)
@echo off
set JAVAOPTS= -Xms20m -Xmx500m %JAVAOPT%
set FILE=
set OPTIONS=
:loop
if "%1" == "" goto break
if "%1" == "-v" goto setOptions
if "%1" == "-print_mndl" goto setOptions
if "%1" == "-verbose" goto setOptions
if "%1" == "-seed" goto setJavaOpt
if "%1" == "-help" goto help
goto break
:setOptions
set OPTIONS=%OPTIONS% %1
shift
goto loop
:setJavaOpt
shift
set JAVAOPTS=%JAVAOPTS% -Drandom.seed=%1
shift
goto loop
:break
if not exist "%1" goto notFound
native2ascii %1 > %1.tmp
set FILE=%1.tmp
shift
java %JAVAOPTS% -classpath classes;lib\simcore.jar;lib\loader.jar jp.go.nict.msf.loader.MNDLParser %OPTIONS% %FILE% %1
del %FILE%
goto end
:help
echo usage: loader -help
echo usage: loader [-v] [-seed value] [-print_mndl] filename.mndl [traceLogFile]
java -classpath classes;lib\simcore.jar;lib\loader.jar jp.go.nict.msf.loader.MNDLParser -help
goto end
:notFound
echo loader: Error "%1" is not found.
echo usage: loader -help
echo usage: loader [-v] [-seed value] [-print_mndl] filename.mndl [traceLogFile]
:endAnd what is the actual quesion then? Because the batch file given above is itself a good example how to use parameters.
Mike -
How to include an image or pdf file in a message for this forum
Can someone please tell me how to include in a message like this one an image or a pdf file?
ThanksRead here _[Help and terms of Use|http://discussions.apple.com/help.jspa]_ which you can also can find in the right panel in the forum
You can put your image on flickr.com or imageshack.us or similar sites. -
How to get result from another JSP file?
I have to write a jsp (my.jsp) to get information from another jsp file (other.jsp).
The other.jsp return integer value (0 / 1) so that user can tell if certain service is available or not. And in my.jsp I need to collect such result and other information from a text file to make up of a XML string.
How can I call other.jsp to get the result? Thanks a lot.Hi, I think I didn't describe the problem clearly
enough. In fact, there is a JSP file, and if our
database is currently connected, the JSP will return
value 1, otherwise, it will return 0. My java program
need to get that result, and then form an XML string,
and send the string back to the client. I'm just
wonder how can I write such a program to read result
from JSP file. Thanks a lot.Why is this function implemented as a JSP file? It should be implemented as a bean. It would be simple to get the information you require from that bean. -
How to call java method in jsp file?
can anyone guide me or teach me how can i call the java method into the jsp file? do i need a main method to call it in? or just call the method that i need 2 use only??
below is the coding that i did. one is java and another one is jsp. hope that someone can help me on it. Thanks!!!! Really appreciate it.
Country Method.java
package Test;
import java.io.File;
import com.db4o.*;
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
public class countryMethod {
public final static String filename = "C:\\TestStore.yap";
public String record;
public int value;
public String cName1;
private static ObjectContainer db = Db4o.openFile(filename);
public static void storeData() {
//Delete existing data file
new File(filename).delete();
//Open Database
db = Db4o.openFile(filename);
//Add value into database
Country c1 = new Country(100, "Malaysia");
Country c2 = new Country(200, "Thailand");
Country c3 = new Country(300, "Sing");
Country c4 = new Country(400, "Japan");
Country c5 = new Country(500, "Indian");
db.set(c1);
db.set(c2);
db.set(c3);
db.set(c4);
db.set(c5);
System.out.println("abc");
public String getData() {
String str = "";
try {
//open database
ObjectContainer db = Db4o.openFile(filename);
//Create empty object
Country country = new Country(0,null);
//Object dataset
ObjectSet result = db.get(country);
//System.out.println(result.size());
while(result.hasNext()){
Country a = (Country)result.next();
record = a.getName();
value = a.getValue();
str = str +" | "+ value;
//System.out.println(str);
//System.out.println(a.getValue());
}catch(Exception s){
s.printStackTrace();
str = str +" | "+ record;
return str;
/*public int getValue(){
return value;
}and the jsp.
<%@page import com.db4o.ObjectContainer%>
<html>
<head><title>Testing page</titile></head>
<body>
<jsp:useBean id="link" class = "Test.countryMethod" />
<%=link.getData() %>
</body>
</html>i try on the easier that i can but still i have error displaying it
here are the files
package com;
public class CountryPeople {
public String name;
private int value;
public CountryPeople(String name, int value){
this.name = "Eric";
this.value = 2;
public String getName() {
return name;
public int getValue(){
return value;
}JSP file will be
<html>
<head><title>Testing page</titile></head>
<body>
<jsp:useBean id="store" class="com.CountryPeople"/>
<jsp:setProperty name="store" property="name" />
<jsp:setProperty name="store" property="value" />
<%= store.getName() %>
<jsp:getProperty name="store" property="name" />
<jsp:getProperty name="store" property="value" />
</body>
</html>JAVA File
<html>
<head><title>Testing page</titile></head>
<body>
<jsp:useBean id="store" class="com.CountryPeople"/>
<jsp:setProperty name="store" property="name" />
<jsp:setProperty name="store" property="value" />
<%= store.getName() %>
<jsp:getProperty name="store" property="name" />
<jsp:getProperty name="store" property="value" />
</body>
</html>The end message is
the error message
at [org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Hope that you guys can me. Thanks -
How to link to the two jsp files
Hi,
In my project I have three files.
1.index.jsp
2.help.jsp
3.result.jsp
So index.jsp contains one label,one text and two buttons.
I already solved that after enter the id in the text box, i click result button to see the result.So I call the result.jsp in my form tag.
<form method="post" action="response.jsp">But Now I also want that when I click help button help.jsp whould be loaded.
can I put two forms to do?
How can I identify this form to this button?
will you please give some idea to do this.
Thank you so much.
Meena.99% of it is javascript and not jsp.
'result' is a javascript string variable. The submitForm() function accepts this variable and assigns it as the value to the hidden field.
When button1 is clicked, 'result' is the string that is passed to the function. So the hidden field's value is set to 'result'. Similarly when the second button is clicked, 'help' is the string that is passed and the hidden field's value is set to 'help'.
The first parameter to the function is the form object which is used inside the function to submit the form after the hidden field has been assigned a value.
what action I have to mention.because I have two jsp files result.jsp or >response.jsp?Mention a standard action, say chooser.jsp. So the request always gets submitted to chooser.jsp
Now remember the hidden field will contain information as to which button was clicked. Based on that, shooser.jsp will forward to either result.jsp or help.jsp
In chooser.jsp
<%if(request.getParameter("type").equals("result")){%>
<jsp:forward page="result.jsp"/>
<%}else{
<jsp:forward page="help.jsp"/>
<%}%>Hope that helps,
ram. -
How to add more than one JSP file for a single JSPDYNPage component
Hello Everyone,
I am creating one portal application which involves JSPDYNPage component, while creating this component one JSP file is also created. But i want one more JSP file for my application ...i.e- for the same JSPDYNPage component. can anybody tell me how to create one more JSP for the same component.
Thanks
Chetan DeshpandeHi Pooja,
I tried the way u said, but when i try to create it(i.e- right click on pagelet folder & then new---> other......the way u said.) it asks for JSP file name but finish button is disabled even after entering the JSP file name.....is it that i am doing something wrong....please guide me for this & one more thing it asks for folder name also ...where to store that file....but when i try to enter anything.It doesn't show or doesn't allow me to do so
Thanks
Chetan -
Import statement in .java files and .jsp files
Guys I have few mysteries about this import statement.
Please correct me if I am wrong.
1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import the class I want to use.That is i have to say
<%@page import="one"%>
and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder.(Note that My.class is created in a folder different from c:\ClassFolder )
But I am wondering why was there no need for me to import one.class in two.java.
(Note I am using JDeveloper and Apache server)
Please help.
In this case the pSo I am wondering in JSP why it doesn't take the class I am looking for from the classpath .
Help.You have to understand Java scoping rules. In the 1st scenario with the two Java files I am guessing neither one of them begins with a package statement. This means that they belong to the default package. When you compile the compiler uses the classpath to resolve method calls looking in the default package since there was no import statement specified in two.java. JSP is a little different. Now I just read this here in these forums a couple of days ago. Since the classfiles generated from the JSP files are not in the CLASSPATH they are loaded by a different classloader. This is why you have to import all references to all classes in the default package.
-
Is it possible to get control of the .SWF files in JSP files
Hi All
In my web application, I got 4 swf buttons which are created by flash and they are embedded in the jsp's. Each button perform the navigation to other page.
this is the jsp file.
<table width="100%" border="0">
<tr>
<td width="2%" height="26"> </td>
<td width="31%"> <object classid="clsid:...." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="BASE" value=".">
<param name="BGCOLOR" value="">
<param name="movie" value="button1.swf">
<param name="quality" value="high">
<embed src="button1.swf" width="100" height="22" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" base="." ></embed>
</object> <font size="-1" face="Arial, Helvetica, sans-serif"> </font></td>
<td width="67%" class="sitemapgy">*Add* </td>
</tr>
<tr>
<td height="26"> </td>
<td><object classid="clsid:..." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="BASE" value=".">
<param name="BGCOLOR" value="">
<param name="movie" value="button2.swf">
<param name="quality" value="high">
<embed src="button2.swf" width="100" height="22" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" base="." ></embed>
</object> </td>
<td class="sitemapgy">*Edit* ;</td>
</tr>
<tr>
<td height="26"> </td>
<td><object classid="clsid:..." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="movie" value="button13.swf">
<param name="quality" value="high">
<param name="base" value=".">
<embed src="button7.swf" base="." quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
</object></td>
<td class="sitemapgy">*Create*</td>
</tr>
<tr>
<td height="26"> </td>
<td><object classid="clsid:.." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="BGCOLOR" value="">
<param name="movie" value="main_print.swf">
<param name="quality" value="high">
<param name="base" value=".">
<embed src="main_print.swf" base="." quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
</object></td>
<td class="sitemapgy"><font face="Arial, Helvetica, sans-serif">*Print*</font></td>
</tr>
<tr>
<td height="26"> </td>
<td><object classid="clsid:..." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22" >
<param name="BGCOLOR" value="">
<param name="BASE" value=".">
<param name="movie" value="button3.swf">
<param name="quality" value="high">
<embed src="button3.swf" width="100" height="22" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" base="." ></embed>
</object></td>
<td class="sitemapgy"><font face="Arial, Helvetica, sans-serif">*_Admin_*</font></td>
</tr>
<tr>
<td height="24"> </td>
<td> </td>
<td> </td>
</tr>
</table>When I click the button3.swf (Admin) button....it navigates to other page...Before that I need to get control of swf button and need to perform some login checks.
Is it possible to get control?
ThanksThanks for your responses, I tried in the same way but when ever it looking at the path "/admin/admin_main.jsp",
its navigating to error page if the username is admin too(abcd).
Can you please help me regarding this.
I am sending you my code and web.xml.
<filter>
<filter-name>ExampleFilter</filter-name>
<filter-class>com.pack.db.ExampleFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ExampleFilter</filter-name>
<url-pattern>/admin/admin_main.jsp</url-pattern>
</filter-mapping>
import java.io.*;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.*;
public class ExampleFilter implements Filter {
private FilterConfig filterConfig=null;
public void init(FilterConfig config) throws ServletException {
this.filterConfig = config;
public void destroy() {
filterConfig = null;
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
RequestDispatcher rd = null;
String userInfo = "";
String userName="";
if (request instanceof HttpServletRequest) {
userInfo = ((HttpServletRequest) request).getUserPrincipal()
.getName();
String[] pieces = userInfo.split("\\\\"); // Firefox sends DOMAIN\USERNAME as UserPrincipal
userName = pieces[pieces.length -1]; // getting the username for which I need to perform check
if(userName!="abcd"){
System.out.println("userName IN ELSE PART:"+userName);
System.out.println("INVALID USER NAME");
rd = request.getRequestDispatcher("/admin/error.html");// i need to forward the response url to error page if the username is not equal to "abcd"
rd.forward(request, response);
else{
chain.doFilter(request, response); // if username="abcd" I need to navigate to normal pages.
Thanks -
Importing .class file into jsp file
i am unable to import a .class file into my .jsp file
please give me the correct method to import and also tell me where to deploy the .class filei am unable to import a .class file into my .jsp
file
please give me the correct method to import and also
tell me where to deploy the .class filehttp://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-JSP.html#Section5 -
Calling RDF files from JSP files
Hi,
I created a report file using Oracle 9i Report Builder and save it as RDF extension.After that I deployed it into the server and it's working properly.But, when I created a simple JSP file(not a report) and try to call that RDF file from this JSP file,the web browser prompts for downloading the entire RDF file.Is there any way to aviod this prompting, and make it to proper ruuning from that JSP ??
Thanks &Regards
Rajesh K.RYou are in the wrong forum
Go to Reports
Maybe you are looking for
-
Laserjet 1300 printer installation
I got an old laserjet 1300 printer from a friend - no driver or manual included. Downloaded the driver from the hp website. My OS is Windows XP. This printer isn't listed for installation purposes. I reviewed the manual for compatible drivers, bu
-
How do I get my contacts from icloud to my iphone?
My phone froze up the other day so I reset it. held down the 2 buttons...I've done this many times before and not lost any data. But this time, when it came back up, all of my contacts were gone. Then it automatically synced with Verizon Backup as
-
my IPad just froze when i was doing my work, its not responding now, i didn't hit it and it is brand new
-
Video podcast is showing in the store; downloading but not playing
Dear Podcast Owner The podcast located at the URL shown below has been blocked or removed from the iTunes directory as a result of technical problems with the feed. If you wish to reactivate your podcast in the iTunes directory, please troubleshoot y
-
Register serial number problem?
i just got this new iPad air 128gb from Amazon, it came from their warehouse as like new, most liking meaning open box. Anyway when k try to go register the serial number to my Apple ID, it says it is already linked to another apple id. How do I go a