VB Instr like function in JSP?
Is there a comparable Java function to VB's Instr function that can be used in JSP. I basically want to look through one string and see if another string exists.
In VB you would just use Instr(stringtocheck,string) and this would return the numeric position in the first string of the second string.
Thanks in advance.
Try String.indexOf(String str).
For example:
String foobar = "foobar";
int barIndex = foobar.indexOf("bar");
(See http://java.sun.com/j2se/1.3/docs/api/index.html).
Similar Messages
-
Access session variable in Java Function in JSP
Hi Experts !!
I am developing an application using STRUTS MVC...
Very sorry if u have problem understanding my question, i ll try to improve... and sorry if i can't post codes here
Basic question is ....
I want to open a word document on pageLoad of JSP, the word document is not a single document, there is a form in which there is a "name" and "template" whenever user clicks on a button there is one action attached to it which creates a copy of that template in a different folder.. on the next page OnLoad i want to open that particular document. for that i have created a variable and also have set in the session, just want to access it in the below code.
I have a formbean in which i have a variable, the scope is session, that variable i have put it in session also. but i want to access that variable in a "java function" in JSP so that "onLoad" page that function should work.
JSP---
<script type="text/javascript">
function openDocument() {
var w = new ActiveXObject("Word.Application");
var docText;
var obj;
var a;
if (w != null) {
w.Visible = true;
obj = w.Documents.Open(I HAVE TO ACCESS THAT VARIABLE HERE);
</script>
FORMBEAN----
public class CreateSOWFormBean extends ActionForm {
private String workflowName;
private String comment;
private String sowTemplate;
private String sowFileCreated;
public String getSowFileCreated() {
return sowFileCreated;
public void setSowFileCreated(String sowFileCreated) {
this.sowFileCreated = sowFileCreated;
sowFileCreated is the variable that i have accessed in session and that value i have to pass in that function in JSP....
I am aware of something like
obj = w.Documents.Open(<%'sowFileCreated'%>);
but i m not sure how to write....
Plz help.....If you're working under a framework like struts you should definitely be using JSTL tags rather than scriptlet code to access variables within the page. With JSTL code <% codes can be almost entirely avoided.
To transfer a value from a Servlet to a JSP don't use a session variable, use a request attribute. Session variables should only be used when values have to survive from one transaction to another.
You can write something like:
obj = w.Documents.open('<c:out value="${openURL}"/>');in the Javascript portion of your JSP.
Just beware of potential problems with quotes. The coresponding code in the Servlet would be like:
request.setAttribute("openURL", openUrl); -
Passing values to JavaBean function using jsp scriplet
Hi,
I have a JavaBean funtion that is SaveData(parameters)
which save the values from HTML form.
Now i want a code for pass the values from HTML form to SaveData() function using jsp scriptlet.
I used the code
<jsp:useBean id="JDBC" class="bean.JDBCBean" scope="application"></jsp:useBean>
<%=JDBC.saveData(phonenumber,manufacturer,model,email,country,newsletter)%>
Here
JDBCBean -> Bean Name
phonenumber,manufacturer,model,email,country,newsletter ->HTML form's text values
But it didnt work properly.
Anyone help me to correct this.Hi,
i have the same code like above
I have to pass the parameters with form name under the following code.
<jsp:useBean id="JDBC" class="bean.JDBCBean" scope="application"></jsp:useBean>
<%=JDBC.saveData(registration.phonenumber.value,id_type.value,id_style.value,registration.email.value,registration.scountry.value,player_type.values)%>
Here
registration -> HTML form name
But i got the error for
package registration does not exist
out.print(JDBC.saveData(registration.phonenumber.value,id_type.value,id_style.value,registration.email.value,registration.scountry.value,player_type.values));
How to i correct this?
Anyone help me...... -
How can I exit a function in JSp
my code is
<%! String Dothis(int level)
if(level==2)
//exit the function
else
%>
How can I exit this function .....
Break label does not work...as I am not able to declare a label
Pl...guide me
smitaLooking into ur code ,,,, U can do it like the following in addition to solutions posted above ( Exception and return)
<%! String Dothis(int level)
if(level != 2)
%>
Thanks
Sampath ... -
HOW CAN I WRITE A EMAIL FUNCTION USING JSP
WHICH HAVE FORWARD, REPLY, REPLAY ALL, AND ADDRESS BOOK LIKE YAHOO EMAIL FUNCTION
HOW CAN I WRITE IT?I meant you would face a considerable challenge trying to write
public static void main(String[] arg) { } with your Caps-Lock key stuck.
You would not even be able to escape your way out of it with
\u0070\u0075\u0062\u006C\u0069\u0063 \u0073\u0074\u0061\u0074\u0069\u0063 \u0076\u006F\u0069\u0064 \u006D\u0061\u0069\u006E(S\u0074\u0072\u0069\u006E\u0067[] \u0061\u0072\u0067) { } as the "\u" escape sequence also contains a lowercase character. -
How to use LIKE function with a parameter in Oracle REPORT builder??
how could i use parameter inside a LIKE function in Oracle reports builder?
it works in SQL plus, but not in report builder!!
Example:
select code,desc from item_master where desc
like '%&give_desc%'; ---works in SQL
like '%:give_desc%' ---doesn't work in report builder!!Hi Renil,
You will need to use the wildcard character (%) and the concatenation character (||) to join to your user parameter.
i.e. like '%'||:give_desc||'%'
Regards,
John -
How to use variable in the LIKE function along with % operators
Hi,
Is there any way i can use the variable in the Like function. That means i have query like
SELECT * FROM Device WHERE DeviceName LIKE %v_MediaName%;
Here "v_MediaName" is the userdefined variable which contains string. I want to retrieve all the records from the "DEVICE" table whose DeviceName LIKE %v_MediaName%;
If i put it in a single quotes '%v_MediaName%' then the v_MediaName will be treaded as a string instead of a variable. I am using this query in a Procedure.
please help me out to resolve the issue.
thanksLIKE '%'||v_MediaName||'%';
Will not make use of the indexes though.
Message was edited by:
satishkandi -
How to call java script function from JSP ?
how to call java script function from JSP ?
i have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks
-
Serach like functionality, parsing
Hi all
I want to implement 'search like functionality' and text parsing' Can someone help where i can find proper documentation for this.
By search like functionality i mean- i have hired XXX and want to find the same candidate in my resume database
Thank youTry looking at
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:688976960025 -
In Jsp TagLib how can I get the Attribute value (like JavaBean) in jsp
Dear Friends,
TagLib how can I get the Attribute value (like JavaBean) in jsp .
I do this thing.
public void setPageContext(PageContext p) {
pc = p;
pc.setAttribute("id", new String("1") );
pc.setAttribute("first_name",new String("Siddharth")); //,pc.SESSION_SCOPE);
pc.setAttribute("last_name", new String("singh"));
but in Jsp
<td>
<%=pageContext.getAttribute("first_name"); %>
cause null is returing.
Pls HELP me
with regards
Siddharth SinghFirst, there is no need to pass in the page context to the tag. It already is present. How you get to it depends on what type of tag:
Using [url http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/SimpleTagSupport.html]SimpleTagSupport
public class MyTag extends SimpleTagSupport
public void doTag()
PageContext pc = (PageContext)getJspContext();
pc.setAttribute("first_name", "Siddharth");
pc.setAttribute("last_name", "Singh");
pc.setAttribute("id", "1");
}Using [url http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/TagSupport.html]TagSupport or it's subclass [url http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/BodyTagSupport.html]BodyTagSupport the page context is aleady declared as an implicit object:
public class MyTag extends TagSupport
public void doStartTag()
pageContext.setAttribute("first_name", "Siddharth");
pageContext.setAttribute("last_name", "Singh");
pageContext.setAttribute("id", "1");
}In each case, this sort of thing should work:
<mytags:MyTag />
<%= pageContext.getAttribute("first_name") %>I -
Sql like function in View Object for progammatically
Hi friends,
I used Jdeveloper 11.1.1.4.0 ,I need how to get the datas from database using sql like function(select * from tablename where name like 'p%') using viewCriteria by
programmatically.
Thanks & Regards,
Priya.
Edited by: priya on Apr 8, 2011 3:48 AM
Edited by: priya on Apr 8, 2011 3:49 AMCheck the docs: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvvo.htm#sm0341
Timo -
Like function in pl/sql code
this is my code
WHERE nvl(dt.DealTicker,'|| '''' || '''' ||') like '%DEALTICKER%'
and dealticker is my one of column name
can you suggest best way to include column name in like function.
fast replies are really appreciated.
thanks,
Vamshi.DIf this is your formatted code, I don't know what 15th and 18th lines do.
SELECT DISTINCT CUSIP,
BB_DealTicker AS DEALTICKER,
Intex_StatusCode AS ''INTEX'',
User_StatusCode AS ''USER'',
HT.CT ,Comment AS ''REMARK'',
CUSIP_COMMENTARY,
CUSIP_RANKING_DESC AS ''CUSIP LEVEL RATING'',
Float_Rate_Ind AS ''FLT'', HT.Sector,
HT.Sub_Sector AS ''SUB SECTOR'',
Ranking AS ''RATING'',
Class,Deal_Desc AS ''DESCRIPTION'',
sp_Rating AS ''S&P'',
moody_Rating AS ''Moody''''s'',
fitch_Rating AS ''Fitch'',
Current_CE' + @tmpFinalStr2 + '
FROM #tmpHoldingTrigger HT,
#DEALTICKER DT
WHERE IsNull(BB_DealTicker,'+ ''''+ ''''+') like ltrim(rtrim(DT.DEALTICKER))+' + ''''+'%'+'''' + '
ORDER BY Intex_StatusCode DESC,
User_StatusCode DESCRemember to post between [pre] and [/pre] or [code] and [/code] tags for a formatted code.
Cheers
Sarma. -
Hi Guyz,
I am having small problem using LIKE function . The problem is I am using LIKE function in the WHERE clause
to compare a column to a particular value, which gets this value from the front end. If the user has a single quote in the string he entered then the LIKE function is not working because of the single quote. Is there any way I can escape the single quote like we escape '%' and '_'.
Thankyou.Mod_plsql supports bind variables, as do almost all front-end tools that deal with Oracle (and most other databases). I do not code mod pl/sql myself, but others here do, and I see bind variables in their code all the time (if I don't, they hear from me :-)).
If you pass a bind variable, the quote problem goes away. As far as I know (which is not very far), you should be able to take the string with the quote directly from your input field, bind it to the variable in your query and have no problems.
I suspect that the reson you are having issues is that you are just gluing strings together to create a sql statement. this is the wrong approach.
The java term for what you are looking for is prepared statement, I'm not sure what the equivalent is i mod plsql, but that should give you a start.
John -
How to realize print function in JSP
How to realize print function in JSP? I know use Javascript:window.print() can print,but it will print whole page,it don't fit me;Another method is to write JSP into Excel and then print it in Excel,but it don't fit me too,because it don't print directly. Anybody know how to print it directly?
Many websites offer a "printer friendly" version of a certain page. That IMO is the only way to solve your problem, next to using CSS to use a different style for printer output. Here is a tutorial that covers this:
http://www.alistapart.com/stories/goingtoprint/ -
How to write printing function using JSP?
dear all,
i want to add a printing function in my project but i do not know how to do it? could anyone teach me how to do it?
thanks
ericsalut eric,
you can do it this way :
1 - create a html link in your code to this javascript
function : (I am using Struts, but you can write it in
pure html
<html:link href="#bodyStart"
onclick="openWindowForPrinting()"
titleKey="msg.status.print"> <bean:message
key='app.print' />
<script language="JavaScript">
<!--
window.open = SymRealWinOpen;
//-->
</script>
</html:link>
>
>
2 - here is the javascript function : it open a window
with the "print.jsp" page.
function openWindowForPrinting(){
window.open('/your_project/pages/common/print.jsp','',
'left=150, top=150 , status=no, directories=no,
toolbar=no, menubar=yes, location=no, scrollbars=yes,
resizable=yes, dependant=yes');
3 : here is the print.jsp page : You have only to
create a session variable called
"currentBodyRelativeLocation", which content the
relative URL to the page you want to print (for
example, the boby of the current page).
<%@ taglib uri='/WEB-INF/tlds/perso.tld'
prefix='perso' %>
<html>
<head>
<perso:csslink page='${cssRelativeLocation}' />
</head>
<body onload="var SymTmpWinOpen = window.open; window.open = SymWinOpen; printPage();; window.open = SymTmpWinOpen;">
<body>
<jsp:include page="${currentBodyRelativeLocation}"/>
</body>
<script language="JavaScript">
<!--
window.open = SymRealWinOpen;
//-->
</script>
</html>
<script language='javascript'>
function printPage(){
window.print();
window.close();
</script>
hai,
i'm not very understand how is your code work. when i write html code, do i need to mind about this code: "msg.status.print" ? what is this code mean?
i have too much question on this thing. would you mind to be further explain to me? or is it any reference for me to refer? i'm really new to write printing function on JSP.
i never write this function before. i'm feel so lost.....:(
thanks again
eric
Maybe you are looking for
-
Font sizing issues with JTextPane
Hello all, I have a question which I hope won't be too difficult. Here is some background. I have created both a swing application that is a text editor. The user can cut, copy, and paste text. The user can also change the "font style" and "font size
-
When I downloaded the update to 10.9.4 on my Macbook, I lost the photos in my two projects in iPhoto. Is there a way to retrieve them?
-
Application localization (.xib files)
Hi, I'm new to iPhone programming, and to this forum, so first of all - hi all I need some help with localizing my app. I know how localization works for .string files, and this part of my project is done and working. However I also have to localize
-
How to add an air printer to I phone 5
How to add a HP 3540 to I phone5
-
Touch ID stopped working on iPhone 6
Got a new iPhone 6. Initially the touch ID setup seemed fine, but after a day it seemed to stop working - as though it couldn't detect that a finger was on the home button. Adding a fingerprint wouldn't work. Did a reset/restart and the had partial j