Hi java/jsp experts, i don't know java/jsp, so please help me out. I want to convert a .jsp to a .java/.class file. is there a tool available, please let me know if you have any pointers.... or can i do it manually: these are a few lines that the .jsp contains, and i would like to translate this to be in .java/.class format:
<%@ page import="sun.misc.BASE64Encoder, javax.crypto., javax.crypto.spec."%>
<%@ page import="java.util.StringTokenizer" %>
<%@ page import="java.util.Map" %>
<%! ....... .......
sb.append("<input type=\"hidden\" name=\"orderPage_serialNumber\" value=\"");
....... ....... %>
how can i translate the above import statements and html elements from jsp to java, please let me know. Once i have the .java file created from the .jsp, I will compile .java to create the .class file and invoke the .class from an ERP program. please help. Thanks in advance.
"jerry the rancher", you have changed your display name from one that is valid, to one that is not. Please restore it.
Joined: Apr 29, 2010
Thanks for your reply, and sorry for asking silly questions, i don't know a lot of java jsp stuff.
could you please tell me should i create a blank .java file in the text editor and just copy paste or should i define a class.
really appreciate your time, can you please give me an example of how i can translate this .jsp file code below to a .java file, what will your .java file look like ?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
I am not so familiar with jsp/java, i can understand i have to include it in the class, but my question is will the conversion from .jsp to .java mean a direct copy paste of all objects ?
how will i translate the html form elements in jsp to java, i mean the ones being appended using the stringbuffer class. i do need them for a transaction.
can i use html elements in .java ?
jerry cowell wrote:can i use html elements in .java ?
You have no real HTML elements. All you are doing is creating strings containing HTML markup.
Perhaps you need to back up a few miles and explain what you are trying to do instead of getting down to nitty-gritty tactics.
Joined: Apr 29, 2010
ok here is what i am trying to do.
I am trying to use a payment gateway to process payments, and the payment vendor has provided a .jsp file(the part of the code above is from that file) that i have to invoke from an ERP program and unfortunately the vendor cannot provide me a .class file and also ERP does not support calls to jsp but has java apis that i can use to invoke a .class file.
and thats what i am planning to do: convert the .jsp to .java to .class file and go from there.
In any case, I assume that the vendor is trying to set things up so you can submit actions to them via the web through HTTP. If you are not doing that, you need to find out what alternate APIs they provide.
At worst, you can send HTTP requests under Java control using classes provided by the java.net package, or even easier by using 3rd party projects like HttpClient.
The first step is to find out what APIs the vendor provides, and choose the one that more closely matches your needs.
Joined: Apr 29, 2010
we have had some discussions with the vendor and this is the only way out.
so i have to convert this .jsp to .class and i can use the api's in my erp and i know that will work.
it would be sweet if you could give me a small sample of how the .java would look like for the .jsp snippet i have provided above.
i will take it from there. i can very well research over the internet and do it myself, the reason to seek help from experts like you is to get some quick help and in turn i can save some time.
Well, the Java code for that "snippet" you posted there is precisely the Java code in it. That's everything but the JSP wrapper with the <% and %> bits. You'll need to wrap it in a class declaration of course and provide the appropriate imports (which you can see there).
The purpose of a JSP is to create an HTML file to show on a web page. That's not going to do anything to communicate with the vendor. All "converting" the JSP over to Java will do is to construct a useless string of HTML markup. What will you do with this string?
What's important is the HTTP API that the vendor expects you to follow. They should have documentation outlining what it is. It could probably (maybe) be garnered second-hand from the JSP (maybe, and certainly painfully), but the JSP itself (and the code within it) is useless except as really really poor "documentation".
Does this vendor not provide documentation on their API beyond really badly-written JSP fragments?
subject: how to convert a .jsp to a .java/.class file