This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes detection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "detection" Watch "detection" New topic
Author

detection

tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40
Hi there!!!
I am new here and new student.

I got a question here.

If I want to detect whether there is an illegal charater(inside red) - other than what is provided now. how do i have to do it? Thanks in advance.

<html>
<body>
<%
for (int i=0;i<5;i++)
{
out.println(i);
}
%>

</body>
</html>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

Welcome to the Ranch.

Question #1: why are you doing this in a JSP? Modern JSP should have no Java code.

Question #2: what is an illegal character? You haven't defined what that means.

Question #3: what have you tried so far? We'll help you with your code, but won't write it for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40
Question #2: what is an illegal character? You haven't defined what that means.

Ans 2: I mean having words like following.

out.println(i); asdf

having asdf @ out.println(i); which is illegal character for the loop(i mean).

Question #3: what have you tried so far? We'll help you with your code, but won't write it for you.

Ans 3: What I got so far is I am able to check the following 2 line having words like above.

1.for (int i=0;i<5;i++)

2.out.println(i);

But, when someone put asdf before and after { } it generate error. So, looking for a solution. thanks for quick replay though.

<html>
<body>
<%
for (int i=0;i<5;i++)
{
out.println(i);
}
%>

</body>
</html>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

So in other words you want to find out whether the Java code in your JSP will compile correctly when you try to use it, right? And the answer is, as Bear said: Don't put Java code into your JSP in the first place. Then the issue doesn't arise.

tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40
This is another issues...

I am trying to answer this for my exam.

I am checking user input error rather than what it should be as following lines

<%
for (int i=0;i<5;i++)
{
out.println(i);
}
%>

There should be nothing rather than what is written, of course, variable and no can change.
Thanks.

I am lost
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Ah, I see. I thought you were looking for some programming tool which would tell you whether your JSP code would compile or not. But you just want a rule which you, yourself, can use? You want to look at some Java code and determine whether it will compile successfully or not?
tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40
yeap ... thanks...any suggestion or recommandation?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: detection