Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import { Text, View, StyleSheet, ImageBackground, TextInput, TouchableOpacity, Alert } from 'react-native';
- export default class Login extends Component {
- static navigationOptions = {
- header: null
- };
- constructor(props) {
- super(props);
- this.state = {
- userName : '',
- userPass : ''
- }
- }
- login = () => {
- const {userName} = this.state;
- const {userPass} = this.state;
- if(userName == '' || userPass == '') {
- Alert.alert('Warning' , 'Please Insert All the Required Details !!!!');
- } else {
- fetch('newjsp1.jsp', {
- method: 'POST',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- name: userName,
- pass: userPass
- }),
- })
- .then(function(response) {
- return response.json();
- })
- .then(function(myJson) {
- console.log(myJson);
- });
- }
- }
- render() {
- return (
- <View style={styles.container}>
- <ImageBackground source={require('../img/1.jpg')} style={styles.backgroundImage}>
- <View style={styles.content}>
- <Text style={styles.logo}> -- LOGIN DEMO -- </Text>
- <View style={styles.inputContainer}>
- <TextInput underlineColorAndroid='transparent' style={styles.input} placeholder='USERNAME' onChangeText = {userName => this.setState({userName})} >
- </TextInput>
- <TextInput underlineColorAndroid='transparent' secureTextEntry={true} style={styles.input} placeholder='PASSWORD' onChangeText = {userPass => this.setState({userPass})} >
- </TextInput>
- </View>
- <TouchableOpacity onPress={this.login} style={styles.buttonContainer}>
- <Text style={styles.buttonText}>LOGIN</Text>
- </TouchableOpacity>
- </View>
- </ImageBackground>
- </View>
- );
- }
- }
- <%
- String user = request.getParameter("name");
- String pass = request.getParameter("pass");
- JSONObject obj = new JSONObject();
- obj.put("USERNAME", user);
- obj.put("PASSWORD", pass);
- out.print(obj);
- %>
Add Comment
Please, Sign In to add comment