简体   繁体   English

如何在Android中实现JSP代码?

[英]How to implement jsp code in android?

I have a webpage which asks for username,password and there is a log in button. 我有一个网页,要求输入用户名,密码,并且有一个登录按钮。 Log in button uses jsp function as follows 登录按钮使用jsp功能如下

function submitData(){ 
            document.getElementById('txtSN').value=document.getElementById('txtRegNumber').value;
            document.getElementById('txtPD').value=document.getElementById('txtPwd').value;
            if(document.getElementById('txtSN').value == '' || document.getElementById('txtSN').length == 0) {
                alert(' Please Enter Student Register No/Studen ID');
                document.getElementById('txtSN').focus();
                return false;
            }

            if(document.getElementById('txtPD').value == '' || document.getElementById('txtPD').length == 0) {
                alert(' Please Enter Password');
                document.getElementById('txtPD').focus();
                return false;
            }
             if(document.getElementById('txtverifycode').value == '' || document.getElementById('txtverifycode').length == 0) {
                alert(' Please Enter Verification Code');
                document.getElementById('txtverifycode').focus();
                return false;
            }

            document.getElementById('txtPA').value=1;
            document.getElementById('txtRegNumber').value="iamalsouser";
            document.getElementById('txtPwd').value="thanksandregards";
            document.getElementById('frmStudentMain').action="youLogin.jsp";
            document.getElementById('frmStudentMain').submit();
        }

Can I use the above code in android. 我可以在android中使用以上代码。 That is I will create two EditText for username and password; 那就是我将为用户名和密码创建两个EditText and I am going to create a function which is going to use above jsp code. 并且我将创建一个将在上述jsp代码中使用的函数。 What my question is, Is it possible to use jsp code for buttons in android?? 我的问题是,是否可以将jsp代码用于android中的按钮? Whether I want to convert the jsp code to java?? 我是否要将jsp代码转换为Java? Actually I am newbie. 其实我是新手。 If my question doesn't sounds good I am sorry about that. 如果我的问题听起来不好,对此我感到抱歉。

Not sure what you want to explain because your snippet is not actually a jsp code but it is javascript function. 不确定您要解释的内容,因为您的代码段实际上不是jsp代码,而是javascript函数。

Regarding jsp implementation in android is, 关于android中的jsp实现,

JSP can't be implemented in Android. 无法在Android中实现JSP。 As JSP is build up using scriptlets and scripting tags which is deployed on server only. 由于JSP是使用仅部署在服务器上的scriptlet和scripting标签构建的。 Server renders that jsp page whenever any request from client came. 每当来自客户端的任何请求到达时,服务器都会渲染该jsp页面。 As a result it will convert data to pure HTML code and server to requester. 结果,它将数据转换为纯HTML代码,然后将服务器转换为请求者。 So, that is not at all possible to do on mobile. 因此,在移动设备上根本不可能做到。

But yes, if you want pure HTML to be display on android that can be possible using Web components of android. 但是可以,如果您希望在Android上显示纯HTML,可以使用android的Web组件进行显示。 You can ajax call (in a way services) to server through it, get result (XML or JSON response), and render it back to your required view using JQuery or pure Javascript. 您可以通过它对服务器进行ajax调用(以某种方式服务),获取结果(XML或JSON响应),然后使用JQuery或纯Javascript将其呈现回所需的视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM